Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -630,11 +630,11 @@ from langchain.chains import RetrievalQA
|
|
630 |
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
|
631 |
from langchain.agents import Tool, initialize_agent
|
632 |
from huggingface_hub import login
|
633 |
-
from parler_tts import ParlerTTSForConditionalGeneration
|
634 |
-
from transformers import AutoTokenizer, AutoFeatureExtractor, set_seed
|
635 |
|
636 |
from transformers.models.speecht5.number_normalizer import EnglishNumberNormalizer
|
637 |
from string import punctuation
|
|
|
|
|
638 |
|
639 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
640 |
|
@@ -672,7 +672,9 @@ def generate_audio(text, description="Thomas speaks with emphasis and excitement
|
|
672 |
prompt = tokenizer(preprocess(text), return_tensors="pt").to(device)
|
673 |
|
674 |
set_seed(SEED)
|
675 |
-
|
|
|
|
|
676 |
audio_arr = generation.cpu().numpy().squeeze()
|
677 |
|
678 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
@@ -682,6 +684,11 @@ def generate_audio(text, description="Thomas speaks with emphasis and excitement
|
|
682 |
logging.debug(f"Audio saved to {temp_audio_path}")
|
683 |
return temp_audio_path
|
684 |
|
|
|
|
|
|
|
|
|
|
|
685 |
|
686 |
# Check if the token is already set in the environment variables
|
687 |
hf_token = os.getenv("HF_TOKEN")
|
@@ -1223,9 +1230,3 @@ with gr.Blocks(theme='Pijush2023/scikit-learn-pijush') as demo:
|
|
1223 |
|
1224 |
demo.queue()
|
1225 |
demo.launch(share=True)
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
|
|
630 |
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
|
631 |
from langchain.agents import Tool, initialize_agent
|
632 |
from huggingface_hub import login
|
|
|
|
|
633 |
|
634 |
from transformers.models.speecht5.number_normalizer import EnglishNumberNormalizer
|
635 |
from string import punctuation
|
636 |
+
from parler_tts import ParlerTTSForConditionalGeneration
|
637 |
+
from transformers import AutoTokenizer, AutoFeatureExtractor, set_seed
|
638 |
|
639 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
640 |
|
|
|
672 |
prompt = tokenizer(preprocess(text), return_tensors="pt").to(device)
|
673 |
|
674 |
set_seed(SEED)
|
675 |
+
input_features = model.get_input_features(prompt.input_ids) # Ensure we have input_features
|
676 |
+
|
677 |
+
generation = model.generate(input_features=input_features, input_ids=inputs.input_ids)
|
678 |
audio_arr = generation.cpu().numpy().squeeze()
|
679 |
|
680 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
|
|
684 |
logging.debug(f"Audio saved to {temp_audio_path}")
|
685 |
return temp_audio_path
|
686 |
|
687 |
+
def install_parler_tts():
|
688 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/huggingface/parler-tts.git"])
|
689 |
+
|
690 |
+
# Call the function to install parler-tts
|
691 |
+
install_parler_tts()
|
692 |
|
693 |
# Check if the token is already set in the environment variables
|
694 |
hf_token = os.getenv("HF_TOKEN")
|
|
|
1230 |
|
1231 |
demo.queue()
|
1232 |
demo.launch(share=True)
|
|
|
|
|
|
|
|
|
|
|
|