Gayatri kancharla commited on
Commit
ad397f0
·
verified ·
1 Parent(s): 40893d1

Delete interface.py

Browse files
Files changed (1) hide show
  1. interface.py +0 -64
interface.py DELETED
@@ -1,64 +0,0 @@
1
- import logging
2
- logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
3
- logger = logging.getLogger(__name__)
4
-
5
- try:
6
- import gradio as gr
7
- from gtts import gTTS
8
- import os
9
- import tempfile
10
- except ImportError as e:
11
- logger.error(f"Failed to import required libraries: {str(e)}. Please run 'pip install -r requirements.txt'.")
12
- raise
13
-
14
- def create_gradio_interface(user_manager):
15
- try:
16
- def process_interaction(audio_path, user_id, language="en"):
17
- if not audio_path:
18
- return "Please record audio.", None
19
-
20
- # Process voice input
21
- result = user_manager.process_voice(audio_path, user_id)
22
-
23
- if "error" in result:
24
- return result["error"], None
25
-
26
- # Generate text-to-speech response
27
- response_text = (f"Analysis: {result['health_indicators']['respiratory'], "
28
- f"{result['health_indicators']['mental_health']}. "
29
- f"{result['disclaimer']}")
30
-
31
- tts = gTTS(text=response_text, lang=language)
32
- temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp3")
33
- tts.save(temp_file.name)
34
-
35
- # Store interaction
36
- user_manager.store_interaction(user_id, result["encrypted_transcription"], response_text)
37
-
38
- return response_text, temp_file.name
39
-
40
- # Define Gradio interface
41
- iface = gr.Interface(
42
- fn=process_interaction,
43
- inputs=[
44
- gr.Audio(type="filepath", label="Record your voice"),
45
- gr.Textbox(label="User ID (optional)", placeholder="Enter user ID"),
46
- gr.Dropdown(choices=["en", "es", "hi", "zh"], label="Language", value="en")
47
- ],
48
- outputs=[
49
- gr.Textbox(label="Health Assessment"),
50
- gr.Audio(label="Voice Response")
51
- ],
52
- title="Smart Voicebot for Public Health",
53
- description="Record your voice for a preliminary health assessment. Not a diagnostic tool.",
54
- theme="default",
55
- css="""
56
- .gradio-container { max-width: 800px; margin: auto; }
57
- .input, .output { font-size: 16px; }
58
- footer { display: none !important; }
59
- """
60
- )
61
- return iface
62
- except Exception as e:
63
- logger.error(f"Error creating Gradio interface: {str(e)}")
64
- raise