import gradio as gr
from asr import transcribe
from tts import synthesize_speech
from lid import identify_language

def main():
    asr_interface = gr.Interface(
        fn=transcribe,
        inputs=[
            gr.Audio(source="microphone", type="filepath", label="Microphone"),
            gr.Audio(source="upload", type="filepath", label="Upload")
        ],
        outputs="text",
        title="Faroese ASR Demo",
        description="Automatic Speech Recognition for Faroese"
    )

    tts_interface = gr.Interface(
        fn=synthesize_speech,
        inputs="text",
        outputs="audio",
        title="Faroese TTS Demo",
        description="Text-to-Speech Synthesis for Faroese"
    )

    lid_interface = gr.Interface(
        fn=identify_language,
        inputs=[
            gr.Audio(source="microphone", type="filepath", label="Microphone"),
            gr.Audio(source="upload", type="filepath", label="Upload")
        ],
        outputs="label",
        title="Language Identification",
        description="Identify the language of the spoken input"
    )

    demo = gr.TabbedInterface([asr_interface, tts_interface, lid_interface], ["ASR", "TTS", "LID"])
    demo.launch()

if __name__ == "__main__":
    main()