GTimothee commited on
Commit
808825f
·
verified ·
1 Parent(s): a775e69

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+ from transformers import pipeline
4
+
5
+ def tts_inference(text, model_name):
6
+ model = {"reference": model_name}
7
+ pipe = pipeline("text-to-speech", model=model['reference'])
8
+ print('Processing...')
9
+ t = time.time()
10
+ output = pipe(text)
11
+ t = time.time() - t
12
+ print(f"Took {round(t)} seconds")
13
+ return (output["audio"], output["sampling_rate"])
14
+
15
+ # List of available TTS models
16
+ available_models = [
17
+ "microsoft/speecht5_tts",
18
+ "facebook/mms-tts-eng",
19
+ "suno/bark"
20
+ ]
21
+
22
+ gr.Interface(
23
+ fn=tts_inference,
24
+ inputs=[
25
+ gr.Textbox(label="Enter text", placeholder="Type something to convert to speech..."),
26
+ gr.Dropdown(available_models, label="Select Model")
27
+ ],
28
+ outputs=gr.Audio(type="numpy", label="Generated Speech"),
29
+ title="Hugging Face TTS Space",
30
+ description="Enter text and generate speech using Hugging Face's text-to-speech models."
31
+ ).launch()