Spaces:
Sleeping
Sleeping
paulbauriegel
commited on
Commit
·
98beb17
1
Parent(s):
9e776bb
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
-
from faster_whisper import WhisperModel
|
|
|
2 |
import pandas as pd
|
3 |
import gradio as gr
|
4 |
import psutil
|
5 |
import time
|
6 |
import whisperx
|
7 |
|
8 |
-
model = WhisperModel('large-v2', device="cuda", compute_type="float16")
|
|
|
9 |
|
10 |
def speech_to_text(mic=None, file=None, lang=None, task='transcribe'):
|
11 |
if mic is not None:
|
@@ -17,11 +19,13 @@ def speech_to_text(mic=None, file=None, lang=None, task='transcribe'):
|
|
17 |
print(lang, task)
|
18 |
|
19 |
time_start = time.time()
|
20 |
-
segments, info = model.transcribe(audio, task=task, language=lang, beam_size=5)
|
|
|
21 |
print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
22 |
|
23 |
# Decode audio to Text
|
24 |
-
objects = [s._asdict() for s in segments]
|
|
|
25 |
print(objects)
|
26 |
time_end = time.time()
|
27 |
time_diff = time_end - time_start
|
|
|
1 |
+
#from faster_whisper import WhisperModel
|
2 |
+
import whisper
|
3 |
import pandas as pd
|
4 |
import gradio as gr
|
5 |
import psutil
|
6 |
import time
|
7 |
import whisperx
|
8 |
|
9 |
+
#model = WhisperModel('large-v2', device="cuda", compute_type="float16")
|
10 |
+
model = whisper.load_model('large-v2')
|
11 |
|
12 |
def speech_to_text(mic=None, file=None, lang=None, task='transcribe'):
|
13 |
if mic is not None:
|
|
|
19 |
print(lang, task)
|
20 |
|
21 |
time_start = time.time()
|
22 |
+
#segments, info = model.transcribe(audio, task=task, language=lang, beam_size=5)
|
23 |
+
results = model.transcribe(audio, task=task, language=lang, beam_size=5)
|
24 |
print("Detected language '%s' with probability %f" % (info.language, info.language_probability))
|
25 |
|
26 |
# Decode audio to Text
|
27 |
+
#objects = [s._asdict() for s in segments]
|
28 |
+
objects = results["segments"]
|
29 |
print(objects)
|
30 |
time_end = time.time()
|
31 |
time_diff = time_end - time_start
|