Spaces:
Runtime error
Runtime error
AndrewRWilliams
commited on
Commit
•
45ee3c1
1
Parent(s):
e00ce00
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import os
|
|
5 |
import re
|
6 |
import unicodedata
|
7 |
import pathlib
|
|
|
8 |
|
9 |
import whisper
|
10 |
from whisper.utils import write_srt
|
@@ -31,14 +32,14 @@ def slugify(value, allow_unicode=False):
|
|
31 |
value = re.sub(r'[^\w\s-]', '', value.lower())
|
32 |
return re.sub(r'[-\s]+', '-', value).strip('-_')
|
33 |
|
34 |
-
def transcribe(file):
|
35 |
|
36 |
-
audio = whisper.load_audio(file.name)
|
37 |
|
38 |
# transcribe_options = dict(beam_size=5, best_of=5, without_timestamps=False)
|
39 |
|
40 |
# result = model.transcribe(file, **transcribe_options)
|
41 |
-
result = model.transcribe(audio)
|
42 |
|
43 |
file_path = pathlib.Path(file.name)
|
44 |
sourceName = file_path.stem[:MAX_FILE_PREFIX_LENGTH] + file_path.suffix
|
|
|
5 |
import re
|
6 |
import unicodedata
|
7 |
import pathlib
|
8 |
+
import asyncio
|
9 |
|
10 |
import whisper
|
11 |
from whisper.utils import write_srt
|
|
|
32 |
value = re.sub(r'[^\w\s-]', '', value.lower())
|
33 |
return re.sub(r'[-\s]+', '-', value).strip('-_')
|
34 |
|
35 |
+
async def transcribe(file):
|
36 |
|
37 |
+
audio = await whisper.load_audio(file.name)
|
38 |
|
39 |
# transcribe_options = dict(beam_size=5, best_of=5, without_timestamps=False)
|
40 |
|
41 |
# result = model.transcribe(file, **transcribe_options)
|
42 |
+
result = await model.transcribe(audio)
|
43 |
|
44 |
file_path = pathlib.Path(file.name)
|
45 |
sourceName = file_path.stem[:MAX_FILE_PREFIX_LENGTH] + file_path.suffix
|