Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -8,15 +8,15 @@ title = "Transcribe speech in several languages"
|
|
8 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
9 |
|
10 |
asr_pipe_audio2Text_Ge = pipeline(task="automatic-speech-recognition", model="jonatasgrosman/wav2vec2-large-xlsr-53-german")
|
11 |
-
asr_pipe_whisper = pipeline(task="automatic-speech-recognition", model="openai/whisper-
|
12 |
|
13 |
def transcribeFile(inputlang, audio_path : str) -> str:
|
14 |
#transcription = asr_pipe_audio2Text_Ge(audio_path)
|
15 |
#transcription = asr_pipe_whisper(audio_path, max_new_tokens=256, generate_kwargs={"task":"transcribe"})
|
16 |
if inputlang == "Auto Detect":
|
17 |
-
transcription = asr_pipe_whisper(audio_path, chunk_length_s=25, stride_length_s=(5,
|
18 |
elif inputlang == "German":
|
19 |
-
transcription = asr_pipe_audio2Text_Ge(audio_path, chunk_length_s=25, stride_length_s=(5,
|
20 |
return transcription["text"]
|
21 |
|
22 |
def translateAudio(audio_path):
|
|
|
8 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
9 |
|
10 |
asr_pipe_audio2Text_Ge = pipeline(task="automatic-speech-recognition", model="jonatasgrosman/wav2vec2-large-xlsr-53-german")
|
11 |
+
asr_pipe_whisper = pipeline(task="automatic-speech-recognition", model="openai/whisper-medium", device=device)
|
12 |
|
13 |
def transcribeFile(inputlang, audio_path : str) -> str:
|
14 |
#transcription = asr_pipe_audio2Text_Ge(audio_path)
|
15 |
#transcription = asr_pipe_whisper(audio_path, max_new_tokens=256, generate_kwargs={"task":"transcribe"})
|
16 |
if inputlang == "Auto Detect":
|
17 |
+
transcription = asr_pipe_whisper(audio_path, chunk_length_s=25, stride_length_s=(5, 5), generate_kwargs={"task":"transcribe"})
|
18 |
elif inputlang == "German":
|
19 |
+
transcription = asr_pipe_audio2Text_Ge(audio_path, chunk_length_s=25, stride_length_s=(5, 5))
|
20 |
return transcription["text"]
|
21 |
|
22 |
def translateAudio(audio_path):
|