My-audio_bot / app.py
abdelati88's picture
Update app.py
a7b25cf verified
import gradio as gr
import edge_tts
import asyncio
async def text_to_speech_edge(text, character):
voice = "ar-EG-SalmaNeural"
pitch = "+0Hz"
if character == "رجل (مصري)":
voice = "ar-EG-ShakirNeural"
elif character == "سيدة (مصرية)":
voice = "ar-EG-SalmaNeural"
elif character == "طفل (محاكاة)":
voice = "ar-EG-SalmaNeural"
pitch = "+50Hz"
elif character == "رجل (سعودي)":
voice = "ar-SA-HamedNeural"
elif character == "سيدة (سعودية)":
voice = "ar-SA-ZariyahNeural"
output_file = "output.mp3"
communicate = edge_tts.Communicate(text, voice, pitch=pitch)
await communicate.save(output_file)
return output_file
with gr.Interface(
fn=text_to_speech_edge,
inputs=[
gr.Textbox(label="اكتب النص هنا", lines=3),
gr.Radio(["رجل (مصري)", "سيدة (مصرية)", "طفل (محاكاة)", "رجل (سعودي)", "سيدة (سعودية)"], label="اختر الصوت", value="سيدة (مصرية)")
],
outputs=gr.Audio(label="الاستماع", type="filepath"),
title="🎙️ بوت الأصوات المتعددة",
description="جرب أصوات مختلفة (مصري، سعودي، وحتى محاكاة صوت طفل!)"
) as demo:
pass
if __name__ == "__main__":
demo.launch(ssr_mode=False)