3v324v23 commited on
Commit
6f44266
1 Parent(s): 49cb8ba

Add application file4

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -2,30 +2,39 @@ import requests
2
  import time
3
  import threading
4
  import gradio as gr
 
 
 
 
5
 
6
  def get_public_ip():
7
  response = requests.get('https://api.ipify.org?format=json')
8
  return response.json()["ip"]
9
 
10
  def simulate_interaction():
11
- # *** Placeholder for simulating activity within a real application ***
12
- print("Simulating interaction...") # Example action
 
 
 
 
13
 
14
  def background_interaction():
15
- """Performs simulated interaction in a background thread"""
16
  while True:
17
  simulate_interaction()
18
- time.sleep(60 * 5) # Simulate interaction every 5 minutes
19
 
20
- # Gradio interface with public IP display
21
  iface = gr.Interface(
22
- fn=get_public_ip,
23
- outputs="text",
24
- title="Public IP Retriever",
25
- description="Displays the approximate public IP address."
 
26
  )
27
 
28
- # Start background interaction thread
29
  interaction_thread = threading.Thread(target=background_interaction)
30
  interaction_thread.start()
31
 
 
2
  import time
3
  import threading
4
  import gradio as gr
5
+ from transformers import pipeline
6
+
7
+ # Load Whisper model (adjust size as needed)
8
+ model = pipeline("automatic-speech-recognition", model="openai/whisper-base")
9
 
10
  def get_public_ip():
11
  response = requests.get('https://api.ipify.org?format=json')
12
  return response.json()["ip"]
13
 
14
  def simulate_interaction():
15
+ # *** Placeholder for simulating activity ***
16
+ print("Simulating interaction...")
17
+
18
+ def transcribe_audio(audio):
19
+ transcription = model(audio)["text"]
20
+ return transcription
21
 
22
  def background_interaction():
23
+ """Placeholder for background interaction"""
24
  while True:
25
  simulate_interaction()
26
+ time.sleep(60 * 5)
27
 
28
+ # Gradio interface with IP display and speech-to-text
29
  iface = gr.Interface(
30
+ [get_public_ip, transcribe_audio],
31
+ [gr.inputs.Textbox(lines=1, placeholder="Public IP will appear here"), gr.inputs.Audio(source="microphone", type="filepath")],
32
+ [gr.outputs.Textbox(), gr.outputs.Textbox()],
33
+ title="Public IP Retriever & Whisper Transcription",
34
+ description="Get your approximate public IP and transcribe audio using Whisper."
35
  )
36
 
37
+ # Start background interaction thread (optional)
38
  interaction_thread = threading.Thread(target=background_interaction)
39
  interaction_thread.start()
40