interface.py 713 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import gradio as gr
  2. from iva import IVA
  3. def IVA_demo(audio, text):
  4. assistant = IVA()
  5. if audio:
  6. print("Am a")
  7. transcript = assistant.transcript(audio)
  8. else:
  9. transcript = text
  10. query_result = assistant.process_query(transcript)
  11. audio_path = assistant.tts(query_result)
  12. return query_result, audio_path
  13. demo = gr.Interface(
  14. fn=IVA_demo,
  15. inputs=[
  16. gr.Audio(
  17. type="filepath",
  18. sources="microphone",
  19. label="Voice input",
  20. show_label=True,
  21. ),
  22. gr.Textbox(info="...or use text input"),
  23. ],
  24. outputs=[
  25. "text",
  26. gr.Audio(type="filepath"),
  27. ],
  28. )
  29. demo.launch(share=True)