| import gradio as gr | |
| from session_manager import NovaSession | |
| from conversation_logic import generate_response | |
| from save_state import save_conversation, load_conversation | |
| from prompts import get_opening_prompt | |
| import audio_utils | |
| nova = NovaSession() | |
| state = {} | |
| def start_conversation(user_audio, session_id=None): | |
| if session_id and session_id in state: | |
| history = load_conversation(session_id) | |
| opening_text = None | |
| else: | |
| session_id = nova.start_session() | |
| opening_text = get_opening_prompt() | |
| history = [{"role": "system", "content": opening_text}] | |
| save_conversation(session_id, history) | |
| user_text = nova.audio_to_text(user_audio) | |
| history.append({"role": "user", "content": user_text}) | |
| nova_response = generate_response(history) | |
| history.append({"role": "assistant", "content": nova_response}) | |
| save_conversation(session_id, history) | |
| response_audio = nova.text_to_audio(nova_response) | |
| return response_audio, session_id | |
| iface = gr.Interface( | |
| fn=start_conversation, | |
| inputs=[gr.Audio(type="filepath", label="Microphone Input"), gr.Textbox(label="Session ID (leave blank to start new)")], | |
| outputs=[gr.Audio(type="filepath", label="Nova Response"), gr.Textbox(label="Session ID")], | |
| live=True, | |
| title="NovaSpeech Therapy", | |
| description="Real-time natural conversation speech therapy assistant" | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() |