Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,17 @@ from autosub import GOOGLE_SPEECH_API_KEY
|
|
5 |
import soundfile as sf
|
6 |
import io
|
7 |
|
8 |
-
|
9 |
textarea { direction: rtl; text-align: right; font-family: Calibri, sans-serif; font-size: 16px;}
|
10 |
"""
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
seg = Segmenter(ffmpeg_path="ffmpeg",model_path="keras_speech_music_noise_cnn.hdf5" , device="cpu",vad_type="vad")
|
13 |
|
14 |
|
@@ -29,6 +36,10 @@ def pcm_to_flac(pcm_data, sample_rate=16000):
|
|
29 |
|
30 |
|
31 |
def transcribe_audio(audio_file,lan):
|
|
|
|
|
|
|
|
|
32 |
recognizer = SpeechRecognizer(language=lan, rate=16000,api_key=GOOGLE_SPEECH_API_KEY, proxies=None)
|
33 |
text=""
|
34 |
isig,wav = seg(audio_file)
|
|
|
5 |
import soundfile as sf
|
6 |
import io
|
7 |
|
8 |
+
cssfa = """
|
9 |
textarea { direction: rtl; text-align: right; font-family: Calibri, sans-serif; font-size: 16px;}
|
10 |
"""
|
11 |
|
12 |
+
|
13 |
+
cssen = """
|
14 |
+
textarea { direction: ltr; text-align: left; font-family: Calibri, sans-serif; font-size: 16px;}
|
15 |
+
"""
|
16 |
+
|
17 |
+
css=""
|
18 |
+
|
19 |
seg = Segmenter(ffmpeg_path="ffmpeg",model_path="keras_speech_music_noise_cnn.hdf5" , device="cpu",vad_type="vad")
|
20 |
|
21 |
|
|
|
36 |
|
37 |
|
38 |
def transcribe_audio(audio_file,lan):
|
39 |
+
if (lan=="en"):
|
40 |
+
css = cssen
|
41 |
+
else:
|
42 |
+
css = cssfa
|
43 |
recognizer = SpeechRecognizer(language=lan, rate=16000,api_key=GOOGLE_SPEECH_API_KEY, proxies=None)
|
44 |
text=""
|
45 |
isig,wav = seg(audio_file)
|