Santipab commited on
Commit
675ffc8
·
verified ·
1 Parent(s): 98d2321

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -25
app.py CHANGED
@@ -6,8 +6,7 @@ import configparser
6
  import requests
7
  import json
8
  import subprocess
9
- import whisper
10
- # Set up API key for aift
11
  st.set_page_config(layout="wide")
12
 
13
  st.markdown(
@@ -34,10 +33,12 @@ st.markdown(
34
  setting.set_api_key('T69FqnYgOdreO5G0nZaM8gHcjo1sifyU')
35
 
36
  # Create two columns
 
37
  col1, col2= st.columns(2)
38
 
39
 
40
  with col1:
 
41
  # Code in the left column
42
  st.markdown(
43
  "<h1 style='text-align: center; font-family: Times New Roman;'>Choose Your Country</h1>",
@@ -68,28 +69,6 @@ with col1:
68
  country = "Chinese"
69
  open("country.txt", "w").write("Chinese")
70
 
71
- audio_value = st.audio_input("Record a voice of you",key=1)
72
- if audio_value is not None:
73
- st.audio(audio_value)
74
- audio_bytes = audio_value.getvalue()
75
- file_path = "./recorded_audio_en.wav"
76
- with open(file_path, "wb") as file:
77
- file.write(audio_bytes)
78
-
79
- audio = AudioSegment.from_wav(file_path)
80
- audio = audio.set_frame_rate(16000).set_channels(1)
81
- output_file = "./recorded_audio_en.wav"
82
- audio.export(output_file, format="wav")
83
- with open(file_path, "wb") as file:
84
- file.write(audio_bytes)
85
- st.success(f"Audio saved and modified as {output_file}")
86
-
87
- if (country := open("country.txt").read().strip()) == "English":
88
- model = whisper.load_model("tiny")
89
- audio = whisper.load_audio("recorded_audio_en.wav")
90
- result = model.transcribe(audio)
91
- st.write(result["text"])
92
-
93
  # elif (country := open("country.txt").read().strip()) == "Chinese":
94
  # elif (country := open("country.txt").read().strip()) == "Thailand":
95
 
@@ -230,4 +209,4 @@ with col2:
230
  st.error("Failed to extract transcript.")
231
 
232
  else:
233
- st.warning("Please select your dialect before recording.")
 
6
  import requests
7
  import json
8
  import subprocess
9
+
 
10
  st.set_page_config(layout="wide")
11
 
12
  st.markdown(
 
33
  setting.set_api_key('T69FqnYgOdreO5G0nZaM8gHcjo1sifyU')
34
 
35
  # Create two columns
36
+
37
  col1, col2= st.columns(2)
38
 
39
 
40
  with col1:
41
+
42
  # Code in the left column
43
  st.markdown(
44
  "<h1 style='text-align: center; font-family: Times New Roman;'>Choose Your Country</h1>",
 
69
  country = "Chinese"
70
  open("country.txt", "w").write("Chinese")
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  # elif (country := open("country.txt").read().strip()) == "Chinese":
73
  # elif (country := open("country.txt").read().strip()) == "Thailand":
74
 
 
209
  st.error("Failed to extract transcript.")
210
 
211
  else:
212
+ st.warning("Please select your dialect before recording.")