emirhanbilgic
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -63,7 +63,7 @@ def combine_audio_arrays(audio_list):
|
|
63 |
combined_audio = np.concatenate(audio_list, axis=0)
|
64 |
return combined_audio
|
65 |
|
66 |
-
@spaces.GPU(duration=
|
67 |
# Function to generate audio for a single sentence
|
68 |
def generate_single_wav_from_text(sentence, description):
|
69 |
torch.manual_seed(SEED)
|
@@ -124,13 +124,25 @@ with gr.Blocks() as demo:
|
|
124 |
combined_audio = combine_audio_arrays(all_audio)
|
125 |
all_text += f"**Sentence**: {sentence}\n\n"
|
126 |
yield (sample_rate, combined_audio), all_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
input_mode.change(
|
129 |
fn=lambda choice: [gr.update(visible=choice == "Upload PDF"), gr.update(visible=choice == "Type Text")],
|
130 |
inputs=input_mode,
|
131 |
-
outputs=[pdf_input, text_input]
|
132 |
)
|
133 |
-
|
134 |
source_lang.change(update_target_lang, inputs=source_lang, outputs=target_lang)
|
135 |
|
136 |
run_button.click(run_pipeline, inputs=[input_mode, pdf_input, text_input, translate_checkbox, source_lang, target_lang, description], outputs=[audio_output, markdown_output])
|
|
|
63 |
combined_audio = np.concatenate(audio_list, axis=0)
|
64 |
return combined_audio
|
65 |
|
66 |
+
@spaces.GPU(duration=25)
|
67 |
# Function to generate audio for a single sentence
|
68 |
def generate_single_wav_from_text(sentence, description):
|
69 |
torch.manual_seed(SEED)
|
|
|
124 |
combined_audio = combine_audio_arrays(all_audio)
|
125 |
all_text += f"**Sentence**: {sentence}\n\n"
|
126 |
yield (sample_rate, combined_audio), all_text
|
127 |
+
examples = [
|
128 |
+
[
|
129 |
+
"Once upon a time, in the depth of winter, when the flakes of snow fell like feathers from the clouds, a queen sat sewing at her pal-ace window, which had a carved frame of black wood.",
|
130 |
+
"In an inferior recording quality, a female speaker delivers her slightly expressive and animated words with a fast pace. There's high level of background noise and a very distant-sounding reverberation. Her voice is slightly higher pitched than average.",
|
131 |
+
None,
|
132 |
+
],
|
133 |
+
[
|
134 |
+
"The Importance of AI Safety.pdf",
|
135 |
+
"Gary's voice is monotone yet slightly fast in delivery, with a very close recording that has no background noise.",
|
136 |
+
None
|
137 |
+
]
|
138 |
+
]
|
139 |
|
140 |
input_mode.change(
|
141 |
fn=lambda choice: [gr.update(visible=choice == "Upload PDF"), gr.update(visible=choice == "Type Text")],
|
142 |
inputs=input_mode,
|
143 |
+
outputs=[pdf_input, text_input],
|
144 |
)
|
145 |
+
gr.Examples(examples=examples, fn=gen_tts, inputs=inputs, outputs=outputs, cache_examples=True)
|
146 |
source_lang.change(update_target_lang, inputs=source_lang, outputs=target_lang)
|
147 |
|
148 |
run_button.click(run_pipeline, inputs=[input_mode, pdf_input, text_input, translate_checkbox, source_lang, target_lang, description], outputs=[audio_output, markdown_output])
|