import gradio as gr import subprocess import threading import time import os def check_dependencies(): """Check and install missing dependencies.""" print("Checking and installing dependencies...") # Create necessary directories os.makedirs("models/speech_encoder", exist_ok=True) os.makedirs("vocoder", exist_ok=True) # Download vocoder if needed (this will be done on deployment) if not os.path.exists("vocoder/g_00500000"): print("Vocoder will be downloaded when deployed") # Return success message return "✅ Setup ready for deployment!" def launch_services(): """Prepare to launch all services.""" return """ # LLaMA-Omni Services When deployed to Gradio Spaces, this app will: 1. Download required models (Whisper, LLaMA-Omni, vocoder) 2. Start the controller 3. Start the model worker 4. Launch the web interface ## Notes - The model will be loaded automatically during deployment - Audio can be processed via both speech input and text input - The full system allows for seamless speech interaction """ # Create the demo with gr.Blocks() as demo: gr.Markdown("# 🦙🎧 LLaMA-Omni Deployment Setup") with gr.Tab("Status"): status = gr.Markdown(launch_services()) with gr.Tab("Setup"): check_btn = gr.Button("Check Dependencies") result = gr.Textbox(label="Setup Status") check_btn.click(check_dependencies, outputs=result) with gr.Tab("About"): gr.Markdown(""" # About LLaMA-Omni LLaMA-Omni is a speech-language model built upon Llama-3.1-8B-Instruct. It supports low-latency and high-quality speech interactions, simultaneously generating both text and speech responses based on speech instructions. ## Features * Built on Llama-3.1-8B-Instruct, ensuring high-quality responses * Low-latency speech interaction with a latency as low as 226ms * Simultaneous generation of both text and speech responses ## License This code is released under the Apache-2.0 License. The model is intended for academic research purposes only and may NOT be used for commercial purposes. Original work by Qingkai Fang, Shoutao Guo, Yan Zhou, Zhengrui Ma, Shaolei Zhang, Yang Feng. """) # Launch the app if __name__ == "__main__": demo.launch()