Spaces:
Runtime error
Runtime error
RamAnanth1
commited on
Commit
·
382782b
1
Parent(s):
2e9ec14
Update app.py
Browse files
app.py
CHANGED
@@ -3,29 +3,25 @@ import gradio as gr
|
|
3 |
import os, json
|
4 |
from loguru import logger
|
5 |
import random
|
6 |
-
import
|
7 |
import torch
|
8 |
|
9 |
session_token = os.environ.get('SessionToken')
|
10 |
# logger.info(f"session_token_: {session_token}")
|
11 |
|
12 |
-
whisper_model = whisper.load_model("medium")
|
13 |
|
14 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
translation = whisper.decode(whisper_model, mel, translate_options)
|
26 |
-
|
27 |
-
print("Translated: " + translation.text)
|
28 |
-
return translation.text
|
29 |
|
30 |
def get_response_from_chatbot(text):
|
31 |
try:
|
|
|
3 |
import os, json
|
4 |
from loguru import logger
|
5 |
import random
|
6 |
+
from transformers import pipeline
|
7 |
import torch
|
8 |
|
9 |
session_token = os.environ.get('SessionToken')
|
10 |
# logger.info(f"session_token_: {session_token}")
|
11 |
|
|
|
12 |
|
13 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
14 |
|
15 |
+
whisper_model = pipeline(
|
16 |
+
task="automatic-speech-recognition",
|
17 |
+
model="openai/whisper-large-v2",
|
18 |
+
chunk_length_s=30,
|
19 |
+
device=device,
|
20 |
+
)
|
21 |
|
22 |
+
def transcribe(audio):
|
23 |
+
text = whisper_model(audio)["text"]
|
24 |
+
return text
|
|
|
|
|
|
|
|
|
25 |
|
26 |
def get_response_from_chatbot(text):
|
27 |
try:
|