Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# app.py
|
2 |
-
# Version: 1.
|
3 |
#---------------------------------------------------------------------------------------------------------------------------------------------
|
4 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
# you may not use this file except in compliance with the License.
|
@@ -61,27 +61,14 @@ SIDEBAR_INFO = f"""
|
|
61 |
# ------------transcribe section------------
|
62 |
|
63 |
|
64 |
-
|
65 |
-
# ============UPDATED============[convert m4a audio to wav]
|
66 |
-
@spaces.GPU()
|
67 |
-
def convert_to_wav(filepath):
|
68 |
-
_,file_ending = os.path.splitext(f'{filepath}')
|
69 |
-
audio_file = filepath.replace(file_ending, ".wav")
|
70 |
-
print("starting conversion to wav")
|
71 |
-
os.system(f'ffmpeg -i "{filepath}" -ar 16000 -ac 1 -c:a pcm_s16le "{audio_file}"')
|
72 |
-
return audio_file
|
73 |
-
# ================================[------------------------]
|
74 |
-
|
75 |
-
|
76 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30, generate_kwargs={'task': 'transcribe', 'language': 'no'})
|
77 |
|
78 |
@spaces.GPU()
|
79 |
-
def transcribe_audio(
|
80 |
-
audio_file = convert_to_wav(audio_file)
|
81 |
|
82 |
with tempfile.NamedTemporaryFile(suffix=".wav") as temp_audio_file:
|
83 |
# --copy contents of uploaded audio file to temporary file
|
84 |
-
temp_audio_file.write(open(
|
85 |
temp_audio_file.flush()
|
86 |
# --use torchaudio to load it
|
87 |
waveform, sample_rate = torchaudio.load(temp_audio_file.name)
|
|
|
1 |
# app.py
|
2 |
+
# Version: 1.07a (08.27.24), ALPHA
|
3 |
#---------------------------------------------------------------------------------------------------------------------------------------------
|
4 |
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
# you may not use this file except in compliance with the License.
|
|
|
61 |
# ------------transcribe section------------
|
62 |
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large", chunk_length_s=30, generate_kwargs={'task': 'transcribe', 'language': 'no'})
|
65 |
|
66 |
@spaces.GPU()
|
67 |
+
def transcribe_audio(audio, batch_size=16):
|
|
|
68 |
|
69 |
with tempfile.NamedTemporaryFile(suffix=".wav") as temp_audio_file:
|
70 |
# --copy contents of uploaded audio file to temporary file
|
71 |
+
temp_audio_file.write(open(audio, "rb").read())
|
72 |
temp_audio_file.flush()
|
73 |
# --use torchaudio to load it
|
74 |
waveform, sample_rate = torchaudio.load(temp_audio_file.name)
|