Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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(
|