Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
28 |
print(f"Bruker enhet: {device}")
|
29 |
|
30 |
@spaces.GPU(duration=60 * 2)
|
31 |
-
def pipe(file, return_timestamps=False,lang="
|
32 |
asr = pipeline(
|
33 |
task="automatic-speech-recognition",
|
34 |
model=MODEL_NAME,
|
@@ -74,10 +74,10 @@ def transcribe(file, return_timestamps=False,lang_nn=False):
|
|
74 |
|
75 |
if not lang_nn:
|
76 |
if not return_timestamps:
|
77 |
-
text = pipe(file_to_transcribe
|
78 |
formatted_text = format_output(text)
|
79 |
else:
|
80 |
-
chunks = pipe(file_to_transcribe, return_timestamps=True
|
81 |
text = []
|
82 |
for chunk in chunks:
|
83 |
start_time = time.strftime('%H:%M:%S', time.gmtime(chunk["timestamp"][0])) if chunk["timestamp"][0] is not None else "??:??:??"
|
|
|
28 |
print(f"Bruker enhet: {device}")
|
29 |
|
30 |
@spaces.GPU(duration=60 * 2)
|
31 |
+
def pipe(file, return_timestamps=False,lang="nn"):
|
32 |
asr = pipeline(
|
33 |
task="automatic-speech-recognition",
|
34 |
model=MODEL_NAME,
|
|
|
74 |
|
75 |
if not lang_nn:
|
76 |
if not return_timestamps:
|
77 |
+
text = pipe(file_to_transcribe)["text"]
|
78 |
formatted_text = format_output(text)
|
79 |
else:
|
80 |
+
chunks = pipe(file_to_transcribe, return_timestamps=True)["chunks"]
|
81 |
text = []
|
82 |
for chunk in chunks:
|
83 |
start_time = time.strftime('%H:%M:%S', time.gmtime(chunk["timestamp"][0])) if chunk["timestamp"][0] is not None else "??:??:??"
|