Omarrran's picture
Create app.py
98a6b3f verified
raw
history blame contribute delete
972 Bytes
import gradio as gr
from elevenlabs.client import ElevenLabs # Import ElevenLabs from elevenlabs.client
from elevenlabs import VoiceSettings
def text_to_speech(api_key, text):
client = ElevenLabs(api_key=api_key)
audio = client.text_to_speech.convert(
voice_id="pMsXgVXv3BLzUgSXRplE",
optimize_streaming_latency="0",
output_format="mp3_22050_32",
text=text,
voice_settings=VoiceSettings(
stability=0.1,
similarity_boost=0.3,
style=0.2,
),
)
return audio
iface = gr.Interface(
fn=text_to_speech,
inputs=[
gr.Textbox(label="API Key"),
gr.Textbox(label="Text to Convert to Speech")
],
outputs=gr.Audio(label="Generated Speech"),
title="Text to Speech with Eleven Labs",
description="Enter your Eleven Labs API key and the text you'd like to convert to speech. The output will be an audio file of the spoken text."
)
iface.launch()