awacke1 commited on
Commit
dc61d2e
·
1 Parent(s): d587e3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -34,15 +34,23 @@ def save_and_play_audio(audio_recorder):
34
  return filename
35
  return None
36
 
 
 
 
 
 
 
 
 
 
 
 
37
  st.title("Speech to Text")
38
  st.write("Record your speech and get the text.")
39
 
40
- audio_recorder = AudioRecorder()
41
- audio_recorder.start()
42
- if st.button("Stop recording"):
43
- audio_recorder.stop()
44
- filename = save_and_play_audio(audio_recorder)
45
- if filename:
46
- output = query(filename)
47
- st.write("Transcription:")
48
- st.write(output)
 
34
  return filename
35
  return None
36
 
37
+ def transcribe_audio(file_path):
38
+ API_URL = "https://tonpixzfvq3791u9.us-east-1.aws.endpoints.huggingface.cloud"
39
+ headers = {
40
+ "Authorization": f"Bearer {openai_key}",
41
+ }
42
+ with open(file_path, 'rb') as f:
43
+ data = {'file': f}
44
+ response = requests.post(API_URL, headers=headers, files=data)
45
+ if response.status_code == 200:
46
+ st.write(response.json())
47
+
48
  st.title("Speech to Text")
49
  st.write("Record your speech and get the text.")
50
 
51
+ # Audio, transcribe, GPT:
52
+ filename = save_and_play_audio(audio_recorder)
53
+ if filename is not None:
54
+ transcription = transcribe_audio(filename)
55
+ st.sidebar.markdown(get_table_download_link(filename), unsafe_allow_html=True)
56
+ filename = None