diff --git a/app/app.py b/app/app.py index ab39b74..19e2f7d 100644 --- a/app/app.py +++ b/app/app.py @@ -111,16 +111,6 @@ def init_set_provider(set_provider): MODEL_PROVIDER = set_provider print(f"Switched to Model Provider: {set_provider}") -# Initial model and TTS voice setup -# if MODEL_PROVIDER == "openai": -# init_openai_model(OPENAI_MODEL) -# #init_openai_tts_voice(OPENAI_TTS_VOICE) -# elif MODEL_PROVIDER == "ollama": -# init_ollama_model(OLLAMA_MODEL) - -# if TTS_PROVIDER == "elevenlabs": -# init_elevenlabs_tts_voice(ELEVENLABS_TTS_VOICE) - # Function to display ElevenLabs quota def display_elevenlabs_quota(): @@ -194,7 +184,7 @@ async def process_and_play(prompt, audio_file_pth): if TTS_PROVIDER == 'openai': output_path = os.path.join(output_dir, 'output.wav') await openai_text_to_speech(prompt, output_path) - print(f"Generated audio file at: {output_path}") + # print(f"Generated audio file at: {output_path}") if os.path.exists(output_path): print("Playing generated audio...") await send_message_to_clients(json.dumps({"action": "ai_start_speaking"})) @@ -205,7 +195,7 @@ async def process_and_play(prompt, audio_file_pth): elif TTS_PROVIDER == 'elevenlabs': output_path = os.path.join(output_dir, 'output.mp3') await elevenlabs_text_to_speech(prompt, output_path) - print(f"Generated audio file at: {output_path}") + # print(f"Generated audio file at: {output_path}") if os.path.exists(output_path): print("Playing generated audio...") await send_message_to_clients(json.dumps({"action": "ai_start_speaking"})) @@ -499,7 +489,6 @@ def save_conversation_history(conversation_history): content = message["content"] file.write(f"{role}: {content}\n") - def transcribe_with_whisper(audio_file): segments, info = whisper_model.transcribe(audio_file, beam_size=5) transcription = "" diff --git a/app/app_logic.py b/app/app_logic.py index e6127d0..87e9e83 100644 --- a/app/app_logic.py +++ b/app/app_logic.py @@ -109,7 +109,7 @@ async def conversation_loop(): current_character = get_current_character() await send_message_to_clients(f"{current_character.capitalize()}: {chatbot_response}") - print(f"{current_character.capitalize()}: {chatbot_response}") + # print(f"{current_character.capitalize()}: {chatbot_response}") def set_env_variable(key: str, value: str): os.environ[key] = value diff --git a/app/main.py b/app/main.py index bd1f15e..cda7871 100644 --- a/app/main.py +++ b/app/main.py @@ -27,9 +27,6 @@ allow_headers=["*"], ) -# @app.on_event("startup") -# async def startup_event(): -# asyncio.create_task(user_chatbot_conversation()) @app.get("/") async def get(request: Request): @@ -84,8 +81,8 @@ async def download_history(): @app.post("/clear_history") async def clear_history(): global conversation_history - conversation_history = [] - save_conversation_history(conversation_history) + conversation_history.clear() # Clear the in-memory conversation history + save_conversation_history(conversation_history) # Save the cleared state to the file return {"status": "cleared"} diff --git a/app/static/js/scripts.js b/app/static/js/scripts.js index 63eb766..f3976fd 100644 --- a/app/static/js/scripts.js +++ b/app/static/js/scripts.js @@ -121,9 +121,10 @@ document.addEventListener("DOMContentLoaded", function() { console.log("Stop conversation message sent"); }); - clearButton.addEventListener('click', function() { + clearButton.addEventListener('click', async function() { messages.innerHTML = ''; - fetch('/clear_history', { method: 'POST' }); + await fetch('/clear_history', { method: 'POST' }); + console.log("Conversation history cleared."); });