Spaces:
Runtime error
Runtime error
check to see if audio is available
Browse files
app.py
CHANGED
|
@@ -7,15 +7,18 @@ pipe = pipeline(task="automatic-speech-recognition",
|
|
| 7 |
model="openai/whisper-small",
|
| 8 |
device="cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
|
|
|
|
| 10 |
def initialize_pipeline(model_name):
|
| 11 |
global pipe
|
| 12 |
pipe = pipeline(task="automatic-speech-recognition",
|
| 13 |
-
|
| 14 |
-
|
| 15 |
return model_name
|
| 16 |
|
| 17 |
|
| 18 |
def transcribe(audio):
|
|
|
|
|
|
|
| 19 |
text = pipe(audio)["text"]
|
| 20 |
return text
|
| 21 |
|
|
|
|
| 7 |
model="openai/whisper-small",
|
| 8 |
device="cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
|
| 10 |
+
|
| 11 |
def initialize_pipeline(model_name):
|
| 12 |
global pipe
|
| 13 |
pipe = pipeline(task="automatic-speech-recognition",
|
| 14 |
+
model=model_name,
|
| 15 |
+
device="cuda" if torch.cuda.is_available() else "cpu")
|
| 16 |
return model_name
|
| 17 |
|
| 18 |
|
| 19 |
def transcribe(audio):
|
| 20 |
+
if audio is None:
|
| 21 |
+
return "No audio input received. Please try again."
|
| 22 |
text = pipe(audio)["text"]
|
| 23 |
return text
|
| 24 |
|