Hunzla commited on
Commit
348afcf
1 Parent(s): 091d793

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -7
app.py CHANGED
@@ -32,35 +32,54 @@ def find_most_similar_command(statement, command_list):
32
  i+=1
33
 
34
  return best_match,reply
35
- def transcribe_the_command(audio,id):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  import soundfile as sf
38
  sample_rate, audio_data = audio
39
  file_name = "recorded_audio.wav"
40
  sf.write(file_name, audio_data, sample_rate)
41
  # Convert stereo to mono by averaging the two channels
42
- print(id)
43
 
44
  transcript = asr_pipe(file_name)["text"]
45
- if id == "transcript_only":
46
  reply=transcript
47
  print(reply)
48
  else:
49
- commands=urdu_data[id]
50
  print(commands)
51
  most_similar_command,reply = find_most_similar_command(transcript, commands)
52
  print(f"Given Statement: {transcript}")
53
  print(f"Most Similar Command: {most_similar_command}\n")
54
  print(reply)
55
-
56
- return reply
57
  # get_text_from_voice("urdu.wav")
58
  import gradio as gr
59
 
60
 
61
  iface = gr.Interface(
62
  fn=transcribe_the_command,
63
- inputs=[gr.inputs.Audio(label="Recorded Audio",source="microphone"),gr.inputs.Textbox(label="id")],
64
  outputs="text",
65
  title="Whisper Small Urdu Command",
66
  description="Realtime demo for Urdu speech recognition using a fine-tuned Whisper small model and outputting the estimated command on the basis of speech transcript.",
 
32
  i+=1
33
 
34
  return best_match,reply
35
+
36
+
37
+ def send_data_to_db(order_id,col_name):
38
+ import requests
39
+
40
+ # API endpoint URL
41
+ url = 'https://pizzahut.softinfix.tech/api/save_order/'+order_id
42
+
43
+ # Data to send (in dictionary format)
44
+ data = {
45
+ col_name: col_value,
46
+ }
47
+
48
+ # Send POST request with data
49
+ response = requests.post(url, data=data)
50
+
51
+ # Print response
52
+ print(response.status_code)
53
+ print(response.text)
54
+
55
+ def transcribe_the_command(audio,menu_id,order_id,db_col="0"):
56
 
57
  import soundfile as sf
58
  sample_rate, audio_data = audio
59
  file_name = "recorded_audio.wav"
60
  sf.write(file_name, audio_data, sample_rate)
61
  # Convert stereo to mono by averaging the two channels
62
+ print(menu_id)
63
 
64
  transcript = asr_pipe(file_name)["text"]
65
+ if menu_id == "transcript_only":
66
  reply=transcript
67
  print(reply)
68
  else:
69
+ commands=urdu_data[menu_id]
70
  print(commands)
71
  most_similar_command,reply = find_most_similar_command(transcript, commands)
72
  print(f"Given Statement: {transcript}")
73
  print(f"Most Similar Command: {most_similar_command}\n")
74
  print(reply)
75
+ return reply
 
76
  # get_text_from_voice("urdu.wav")
77
  import gradio as gr
78
 
79
 
80
  iface = gr.Interface(
81
  fn=transcribe_the_command,
82
+ inputs=[gr.inputs.Audio(label="Recorded Audio",source="microphone"),gr.inputs.Textbox(label="id"),,gr.inputs.Textbox(label="col_name(optional)")],
83
  outputs="text",
84
  title="Whisper Small Urdu Command",
85
  description="Realtime demo for Urdu speech recognition using a fine-tuned Whisper small model and outputting the estimated command on the basis of speech transcript.",