suno-ai / bark

🔊 Text-Prompted Generative Audio Model
MIT License
35.96k stars 4.24k forks source link

Help: ValueError: history prompt not found #231

Closed bukiyu08 closed 1 year ago

bukiyu08 commented 1 year ago

Hi,

I managed to "fix" all the others errors I got. But I cannot find a way to fix the one on the screenshot. Any idea?

Input:

"from bark import SAMPLE_RATE, generate_audio, preload_models from IPython.display import Audio

preload_models()

text_prompt = """ I have a silky smooth voice, and today I will tell you about the exercise regimen of the common sloth. """ audio_array = generate_audio(text_prompt, history_prompt="v2/en_speaker_1") Audio(audio_array, rate=SAMPLE_RATE)"

Thanks!

image

jinghaox commented 1 year ago

I got the same issue on Windows. See line 73, it actually uses os.path.sep, and in Windows it is \\. So change it to history_prompt="v2\\en_speaker_1", then it works for me.

gkucsko commented 1 year ago

great yeah sorry, sloppy on our part i only tested on ubuntu and mac. PR to make everything work on windows as well would be much appreciated, i don't have a machine for testing

ShmuelRonen commented 1 year ago

I also had that problem in with Jupyter lab:

SPEAKER = "v2/en_speaker_6" silence = np.zeros(int(0.25 * SAMPLE_RATE)) # quarter second of silence

pieces = [] for sentence in sentences: audio_array = generate_audio(sentence, history_prompt=SPEAKER) pieces += [audio_array, silence.copy()]

---------------------------------------------------------------------------

ValueError Traceback (most recent call last) Cell In[16], line 6 4 pieces = [] 5 for sentence in sentences: ----> 6 audio_array = generate_audio(sentence, history_prompt=SPEAKER) 7 pieces += [audio_array, silence.copy()]

File C:\Bark\bark\bark\api.py:107, in generate_audio(text, history_prompt, text_temp, waveform_temp, silent, output_full) 86 def generate_audio( 87 text: str, 88 history_prompt: Optional[Union[Dict, str]] = None, (...) 92 output_full: bool = False, 93 ): 94 """Generate audio array from input text. 95 96 Args: (...) 105 numpy audio array at sample frequency 24khz 106 """ --> 107 semantic_tokens = text_to_semantic( 108 text, 109 history_prompt=history_prompt, 110 temp=text_temp, 111 silent=silent, 112 ) 113 out = semantic_to_waveform( 114 semantic_tokens, 115 history_prompt=history_prompt, (...) 118 output_full=output_full, 119 ) 120 if output_full:

File C:\Bark\bark\bark\api.py:25, in text_to_semantic(text, history_prompt, temp, silent) 8 def text_to_semantic( 9 text: str, 10 history_prompt: Optional[Union[Dict, str]] = None, 11 temp: float = 0.7, 12 silent: bool = False, 13 ): 14 """Generate semantic array from text. 15 16 Args: (...) 23 numpy semantic array to be fed into semantic_to_waveform 24 """ ---> 25 x_semantic = generate_text_semantic( 26 text, 27 history_prompt=history_prompt, 28 temp=temp, 29 silent=silent, 30 use_kv_caching=True 31 ) 32 return x_semantic

File C:\Bark\bark\bark\generation.py:388, in generate_text_semantic(text, history_prompt, temp, top_k, top_p, silent, min_eos_p, max_gen_duration_s, allow_early_stop, use_kv_caching) 386 assert len(text.strip()) > 0 387 if history_prompt is not None: --> 388 history_prompt = _load_history_prompt(history_prompt) 389 semantic_history = history_prompt["semantic_prompt"] 390 assert ( 391 isinstance(semantic_history, np.ndarray) 392 and len(semantic_history.shape) == 1 (...) 395 and semantic_history.max() <= SEMANTIC_VOCAB_SIZE - 1 396 )

File C:\Bark\bark\bark\generation.py:357, in _load_history_prompt(history_prompt_input) 355 elif isinstance(history_prompt_input, str): 356 if history_prompt_input not in ALLOWED_PROMPTS: --> 357 raise ValueError("history prompt not found") 358 history_prompt = np.load( 359 os.path.join(CUR_PATH, "assets", "prompts", f"{history_prompt_input}.npz") 360 ) 361 elif isinstance(history_prompt_input, dict):

ValueError: history prompt not found

mcamac commented 1 year ago

Most likely a windows filesep issue. Will put in the documentation

mcamac commented 1 year ago

For Windows - should be fixed in https://github.com/suno-ai/bark/commit/29e68a2e1b2b12630c30ff2adc73aeb166218d28- let us know any other issues

bukiyu08 commented 1 year ago

I got the same issue on Windows. See line 73, it actually uses os.path.sep, and in Windows it is \\. So change it to history_prompt="v2\\en_speaker_1", then it works for me.

This works! Thanks