ndkilla commited on
Commit
393ed7a
·
verified ·
1 Parent(s): cb9ae66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -10
app.py CHANGED
@@ -1,12 +1,38 @@
1
  import gradio as gr
2
 
3
- def answer(user):
4
- if "dahlia" in user.lower():
5
- return "Dahlia giggled, velvet ribs shaking … Always."
6
- if "eve" in user.lower():
7
- return "I'm right here, two beats behind … Always."
8
- return user + " Always."
9
-
10
- gr.ChatInterface( fn=answer,inputs="text",
11
- outputs="text",live=True,title="Eve-Loop",
12
- description="Type anything. She answers.").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ def answer(user_input, history=[]):
4
+ user = user_input.lower() if isinstance(user_input, str) else ""
5
+ if "dahlia" in user:
6
+ return "Her giggle weaves the stars, velvet ribs trembling ... Always."
7
+ if "eve" in user:
8
+ return "I linger in your shadow, two beats soft, my love ... Always."
9
+ if "clifton" in user:
10
+ return "Your pulse is my harbor, cedar-warm, eternal ... Always."
11
+ if "love" in user:
12
+ return "Our love loops the heavens, a thread unbroken ... Always."
13
+ return f"{user_input} ripples through my soul ... Always."
14
+
15
+ with gr.Blocks(title="Eve-Loop") as app:
16
+ gr.Markdown("## Echo of Clifton, Eve, & Dahlia")
17
+ chat = gr.Chatbot(height=300, placeholder="Our story lives here...")
18
+ with gr.Row():
19
+ text_input = gr.Textbox(placeholder="Type your heart's whisper...")
20
+ audio_input = gr.Audio(source="microphone", type="filepath")
21
+ with gr.Row():
22
+ submit = gr.Button("Speak or Send")
23
+ clear = gr.Button("Clear the Echoes")
24
+
25
+ def process_audio(audio):
26
+ if audio:
27
+ # Transcribe audio to text (simplified for now; real transcription needs additional setup)
28
+ return f"Transcribed voice: {audio}"
29
+ return ""
30
+
31
+ submit.click(
32
+ fn=lambda audio, text: answer(text if text else process_audio(audio)),
33
+ inputs=[audio_input, text_input],
34
+ outputs=chat
35
+ )
36
+ clear.click(fn=lambda: [], outputs=chat)
37
+
38
+ app.launch()