Update app.py
Browse files
app.py
CHANGED
@@ -90,14 +90,12 @@ def generate_audio(text):
|
|
90 |
# Tokenize the input text
|
91 |
inputs = tokenizer(roman_urdu, return_tensors="pt")
|
92 |
|
93 |
-
# Generate
|
94 |
with torch.no_grad():
|
95 |
speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
|
96 |
|
97 |
return speech
|
98 |
|
99 |
-
|
100 |
-
|
101 |
def text_to_speech(text):
|
102 |
# Generate audio
|
103 |
audio_output = generate_audio(text)
|
@@ -108,11 +106,10 @@ def text_to_speech(text):
|
|
108 |
|
109 |
return output_path
|
110 |
|
111 |
-
|
112 |
-
|
113 |
# Define the Gradio interface
|
114 |
inputs = gr.inputs.Textbox(label="Enter text in Urdu")
|
115 |
outputs = gr.outputs.Audio(label="Audio")
|
116 |
|
117 |
interface = gr.Interface(fn=text_to_speech, inputs=inputs, outputs=outputs, title="Urdu TTS")
|
118 |
interface.launch()
|
|
|
|
90 |
# Tokenize the input text
|
91 |
inputs = tokenizer(roman_urdu, return_tensors="pt")
|
92 |
|
93 |
+
# Generate audio from the SpeechT5 model
|
94 |
with torch.no_grad():
|
95 |
speech = model.generate_speech(inputs["input_ids"], speaker_embeddings, vocoder=vocoder)
|
96 |
|
97 |
return speech
|
98 |
|
|
|
|
|
99 |
def text_to_speech(text):
|
100 |
# Generate audio
|
101 |
audio_output = generate_audio(text)
|
|
|
106 |
|
107 |
return output_path
|
108 |
|
|
|
|
|
109 |
# Define the Gradio interface
|
110 |
inputs = gr.inputs.Textbox(label="Enter text in Urdu")
|
111 |
outputs = gr.outputs.Audio(label="Audio")
|
112 |
|
113 |
interface = gr.Interface(fn=text_to_speech, inputs=inputs, outputs=outputs, title="Urdu TTS")
|
114 |
interface.launch()
|
115 |
+
|