Futuresony commited on
Commit
179f501
·
verified ·
1 Parent(s): a2f2a2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
- import soundfile as sf
4
  import torch
5
  from transformers import pipeline
 
6
 
7
  # Set up your TTS model (as before)
8
  synthesiser = pipeline("text-to-speech", "Futuresony/output")
@@ -49,11 +49,8 @@ def respond(
49
  # Generate speech from the text response
50
  speech = synthesiser(response, forward_params={"speaker_embeddings": speaker_embedding})
51
 
52
- # Save the speech to a file (you can play it on the fly or return it in other formats like MP3)
53
- sf.write("generated_speech.wav", speech["audio"], samplerate=speech["sampling_rate"])
54
-
55
- return response, "generated_speech.wav"
56
- # You can return the text along with speech if needed
57
 
58
 
59
  # Create the Gradio interface
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
3
  import torch
4
  from transformers import pipeline
5
+ from datasets import load_dataset
6
 
7
  # Set up your TTS model (as before)
8
  synthesiser = pipeline("text-to-speech", "Futuresony/output")
 
49
  # Generate speech from the text response
50
  speech = synthesiser(response, forward_params={"speaker_embeddings": speaker_embedding})
51
 
52
+ # Return the audio as a Gradio audio component
53
+ return response, speech["audio"]
 
 
 
54
 
55
 
56
  # Create the Gradio interface