bark
bark copied to clipboard
Pls help me with long text voice problem
when i ran long text voice test codes, there were some errors on the screen. Pls help me how to fix it. Thanks.
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
from IPython.display import Audio import nltk # we'll use this to split into sentences import numpy as np
from bark.generation import ( ... generate_text_semantic, ... preload_models, ... ) torch version does not support flash attention. You will get significantly faster inference speed by upgrade torch to newest version / nightly. from bark.api import semantic_to_waveform from bark import generate_audio, SAMPLE_RATE preload_models() speaker_lookup = {"Samantha": "v2/en_speaker_9", "John": "v2/en_speaker_2"}
Script generated by chat GPT
script = """ ... Samantha: Hey, have you heard about this new text-to-audio model called "Bark"? ... ... John: No, I haven't. What's so special about it? ... ... Samantha: Well, apparently it's the most realistic and natural-sounding text-to-audio model out there right now. People are saying it sounds just like a real person speaking. ... ... John: Wow, that sounds amazing. How does it work? ... ... Samantha: I think it uses advanced machine learning algorithms to analyze and understand the nuances of human speech, and then replicates those nuances in its own speech output. ... ... John: That's pretty impressive. Do you think it could be used for things like audiobooks or podcasts? ... ... Samantha: Definitely! In fact, I heard that some publishers are already starting to use Bark to create audiobooks. And I bet it would be great for podcasts too. ... ... John: I can imagine. It would be like having your own personal voiceover artist. ... ... Samantha: Exactly! I think Bark is going to be a game-changer in the world of text-to-audio technology.""" script = script.strip().split("\n") script = [s.strip() for s in script if s] script ['Samantha: Hey, have you heard about this new text-to-audio model called "Bark"?', "John: No, I haven't. What's so special about it?", "Samantha: Well, apparently it's the most realistic and natural-sounding text-to-audio model out there right now. People are saying it sounds just like a real person speaking.", 'John: Wow, that sounds amazing. How does it work?', 'Samantha: I think it uses advanced machine learning algorithms to analyze and understand the nuances of human speech, and then replicates those nuances in its own speech output.', "John: That's pretty impressive. Do you think it could be used for things like audiobooks or podcasts?", 'Samantha: Definitely! In fact, I heard that some publishers are already starting to use Bark to create audiobooks. And I bet it would be great for podcasts too.', 'John: I can imagine. It would be like having your own personal voiceover artist.', 'Samantha: Exactly! I think Bark is going to be a game-changer in the world of text-to-audio technology.'] pieces = [] silence = np.zeros(int(0.5*SAMPLE_RATE)) for line in script: ... speaker, text = line.split(": ") ... audio_array = generate_audio(text, history_prompt=speaker_lookup[speaker], ) ... pieces += [audio_array, silence.copy()] ... Traceback (most recent call last): File "
", line 3, in File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\bark\api.py", line 107, in generate_audio semantic_tokens = text_to_semantic( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\bark\api.py", line 25, in text_to_semantic x_semantic = generate_text_semantic( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\bark\generation.py", line 385, in generate_text_semantic assert (history_prompt in ALLOWED_PROMPTS) AssertionError Audio(np.concatenate(pieces), rate=SAMPLE_RATE) Traceback (most recent call last): File " ", line 1, in File "<array_function internals>", line 200, in concatenate ValueError: need at least one array to concatenate save audio to disk
write_wav("C:\bark_generation.wav", SAMPLE_RATE,np.concatenate(pieces) ) Traceback (most recent call last): File "
", line 1, in NameError: name 'write_wav' is not defined