Update audio2text/a2t.py
Browse files- audio2text/a2t.py +3 -2
audio2text/a2t.py
CHANGED
@@ -5,6 +5,7 @@ import torch
|
|
5 |
from .init import pipe
|
6 |
|
7 |
LIMIT = 90 # limit 90 seconds
|
|
|
8 |
|
9 |
class A2T:
|
10 |
def __init__(self, mic):
|
@@ -42,7 +43,7 @@ class A2T:
|
|
42 |
if inputs is None:
|
43 |
print("Inputs None")
|
44 |
|
45 |
-
transcribed_text = pipe(inputs, generate_kwargs={"task":
|
46 |
return transcribed_text
|
47 |
|
48 |
|
@@ -59,7 +60,7 @@ class A2T:
|
|
59 |
# inputs = processor(audio=audio, sampling_rate=16000, return_tensors="pt")
|
60 |
# predicted_ids = model.generate(**inputs, max_length=400, forced_decoder_ids=forced_decoder_ids)
|
61 |
# transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
62 |
-
return __transcribe(inputs=audio)
|
63 |
except Exception as e:
|
64 |
print("Predict error", e)
|
65 |
return "Oops some kinda error"
|
|
|
5 |
from .init import pipe
|
6 |
|
7 |
LIMIT = 90 # limit 90 seconds
|
8 |
+
TASK = "transcribe"
|
9 |
|
10 |
class A2T:
|
11 |
def __init__(self, mic):
|
|
|
43 |
if inputs is None:
|
44 |
print("Inputs None")
|
45 |
|
46 |
+
transcribed_text = pipe(inputs, generate_kwargs={"task": task}, return_timestamps=True)["text"]
|
47 |
return transcribed_text
|
48 |
|
49 |
|
|
|
60 |
# inputs = processor(audio=audio, sampling_rate=16000, return_tensors="pt")
|
61 |
# predicted_ids = model.generate(**inputs, max_length=400, forced_decoder_ids=forced_decoder_ids)
|
62 |
# transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
63 |
+
return self.__transcribe(inputs=audio, task=TASK)
|
64 |
except Exception as e:
|
65 |
print("Predict error", e)
|
66 |
return "Oops some kinda error"
|