from microsoft_tts import edge_tts_pipeline import gradio as gr import click from lang_data import languages # TTS function def tts(text, Language='English', Gender='Male', translate_text_flag=False, no_silence=True): voice_name = None tts_save_path = '' speed = 1.0 # Set speed directly in the function edge_save_path = edge_tts_pipeline( text, Language, voice_name, Gender, translate_text_flag=translate_text_flag, no_silence=no_silence, speed=speed, tts_save_path=tts_save_path, long_sentence=True # Always set long_sentence to True ) return edge_save_path # Gradio setup source_lang_list = ['English'] source_lang_list.extend(languages.keys()) @click.command() @click.option("--debug", is_flag=True, default=False, help="Enable debug mode.") @click.option("--share", is_flag=True, default=False, help="Enable sharing of the interface.") def main(debug, share): description = """""" gr.Markdown(description) # Define Gradio inputs and outputs example = [ ["This is just the beginning of the journey of HundAI Solutions, HundAI will continue to build AI tools for Hund Ecosystem.", "English", "Female"], ["これは、HundAIソリューションの旅の始まりに過ぎません。HundAIはHundエコシステムのためにAIツールを構築し続けます。", "Japanese", "Female"], ["Это только начало пути HundAI Solutions. HundAI будет продолжать создавать AI-инструменты для экосистемы Hund.", "Russian", "Female"], ["Bu, HundAI Çözümleri yolculuğunun sadece başlangıcıdır. HundAI, Hund Ekosistemi için AI araçları oluşturmaya devam edecektir.", "Turkish", "Female"], ["这只是HundAI解决方案旅程的开始。HundAI将继续为Hund生态系统构建AI工具。", "Chinese", "Female"] ] gradio_inputs = [ gr.Textbox(label="Enter Your Text", lines=3, placeholder="Start typing..."), gr.Dropdown(label="Speaker Origin", choices=source_lang_list, value="English"), gr.Dropdown(label="Gender", choices=['Male', 'Female'], value="Female") ] gradio_outputs = [ gr.Audio(label="Audio File") ] # Apply theme theme = 'Hev832/Applio' # Replace with your desired Hugging Face theme # Create Gradio interface demo = gr.Interface( fn=tts, inputs=gradio_inputs, outputs=gradio_outputs, title="", examples=example, theme=theme # Apply the theme here ) # Launch Gradio with command-line options demo.queue().launch(allowed_paths=[f"./audio"], debug=debug, share=share) if __name__ == "__main__": main()