sssssungk commited on
Commit
43b7ecc
ยท
verified ยท
1 Parent(s): bd61fdc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -3
app.py CHANGED
@@ -29,6 +29,8 @@ import gradio as gr
29
 
30
  import shutil
31
 
 
 
32
 
33
  # ์˜ค๋””์˜ค ๋ณ€ํ™˜ mp4 --> wav
34
  def extract_audio_from_video(video_file_path, audio_file_path):
@@ -134,6 +136,28 @@ def real_fake_check(list_dir, path, model):
134
  return {'real':r_cnt, 'fake':f_cnt, 'prob': prob}
135
 
136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  def main(file_name):
138
 
139
  if os.path.exists('/tmp/wav'):
@@ -171,11 +195,19 @@ def main(file_name):
171
  fake = os.listdir(fake_path)
172
 
173
  rf_check = real_fake_check(fake, fake_path,model) #fake dataset\
174
- return rf_check
 
 
 
 
 
 
 
 
175
 
176
  def deepvoice_check(video_file):
177
- results = main(video_file)
178
- return results
179
 
180
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
181
  deepfake = gr.Interface(
 
29
 
30
  import shutil
31
 
32
+ import speech_recognition as sr
33
+
34
 
35
  # ์˜ค๋””์˜ค ๋ณ€ํ™˜ mp4 --> wav
36
  def extract_audio_from_video(video_file_path, audio_file_path):
 
136
  return {'real':r_cnt, 'fake':f_cnt, 'prob': prob}
137
 
138
 
139
+ # ์Œ์„ฑ์—์„œ text ์ถ”์ถœ
140
+ def convert_wav_to_text(wav_file_path):
141
+ recognizer = sr.Recognizer()
142
+
143
+ # WAV ํŒŒ์ผ ์—ด๊ธฐ
144
+ with sr.AudioFile(wav_file_path) as source:
145
+ print("WAV ํŒŒ์ผ์—์„œ ์˜ค๋””์˜ค๋ฅผ ๋กœ๋“œ ์ค‘...")
146
+ audio_data = recognizer.record(source) # ์ „์ฒด ์˜ค๋””์˜ค๋ฅผ ๋…น์Œ
147
+
148
+ try:
149
+ # Google Web Speech API๋กœ ํ…์ŠคํŠธ ๋ณ€ํ™˜
150
+
151
+ text = recognizer.recognize_google(audio_data)
152
+
153
+ except sr.UnknownValueError:
154
+ text = 'error'
155
+ except sr.RequestError as e:
156
+ text = 'error'
157
+
158
+ return text
159
+
160
+
161
  def main(file_name):
162
 
163
  if os.path.exists('/tmp/wav'):
 
195
  fake = os.listdir(fake_path)
196
 
197
  rf_check = real_fake_check(fake, fake_path,model) #fake dataset\
198
+
199
+ text_list =[]
200
+ to_text = os.listdir('/tmp/wav')
201
+ for i in to_text:
202
+ text = convert_wav_to_text(os.path.join(path, i))
203
+ text_list.append(text)
204
+
205
+
206
+ return rf_check, text_list
207
 
208
  def deepvoice_check(video_file):
209
+ results,text = main(video_file)
210
+ return results,text
211
 
212
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์„ฑ
213
  deepfake = gr.Interface(