File size: 824 Bytes
1845fa8
684979f
 
1845fa8
684979f
1845fa8
4151c7e
684979f
2903326
88c0a73
 
 
 
 
2903326
684979f
 
 
 
 
 
 
 
 
 
 
 
 
1845fa8
684979f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
from IPython.display import Audio
from transformers import pipeline

pipe = pipeline("text-to-speech", model="suno/bark-small")

def text_to_speech(text):
    output = pipe(text)
    print(output)  # Debug print
    if len(output) > 0 and "audio" in output[0] and "sampling_rate" in output[0]:
        audio = Audio(output[0]["audio"], rate=output[0]["sampling_rate"])
        return audio
    else:
        return None
        
iface = gr.Interface(
    fn=text_to_speech,
    inputs="text",
    outputs="audio",
    title="Text-to-Speech",
    description="Convert text to speech using Hugging Face's TTS model",
    examples=[
        ["Hello, how are you?"],
        ["Could you please repeat that?"],
        ["This is a test."],
    ],
    article="https://huggingface.co/models",
)

iface.launch()