Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from pyannote.audio import Pipeline
|
|
6 |
import torch
|
7 |
from pydub import AudioSegment
|
8 |
from pydub.playback import play
|
9 |
-
from datetime import datetime
|
10 |
import time
|
11 |
from silero_vad import load_silero_vad, read_audio, get_speech_timestamps
|
12 |
|
@@ -50,11 +50,11 @@ def transcribe(diarise, how_diarise, audio):
|
|
50 |
if line.strip() != "":
|
51 |
res = line.split(" ")
|
52 |
start = int(float(res[0]) * sr)
|
53 |
-
start_time = str(datetime.fromtimestamp(start / sr)).split()[1]
|
54 |
start_time_prts = start_time.split(":")
|
55 |
start_time_srt = f"{start_time_prts[0]}:{start_time_prts[1]}:{float(start_time_prts[2]):.3f}".replace('.', ',')
|
56 |
end = int(float(res[1]) * sr)
|
57 |
-
end_time = str(datetime.fromtimestamp(end / sr)).split()[1]
|
58 |
end_time_prts = end_time.split(":")
|
59 |
end_time_srt = f"{end_time_prts[0]}:{end_time_prts[1]}:{float(end_time_prts[2]):.3f}".replace('.', ',')
|
60 |
label = res[2]
|
@@ -72,12 +72,12 @@ def transcribe(diarise, how_diarise, audio):
|
|
72 |
for i, line in enumerate(speech_timestamps):
|
73 |
start = line['start']
|
74 |
print(start)
|
75 |
-
start_time = str(datetime.fromtimestamp(start / sr)).split()[1]
|
76 |
start_time_prts = start_time.split(":")
|
77 |
start_time_srt = f"{start_time_prts[0]}:{start_time_prts[1]}:{float(start_time_prts[2]):.3f}".replace('.', ',')
|
78 |
print(start_time_srt)
|
79 |
end = line['end']
|
80 |
-
end_time = str(datetime.fromtimestamp(end / sr)).split()[1]
|
81 |
end_time_prts = end_time.split(":")
|
82 |
end_time_srt = f"{end_time_prts[0]}:{end_time_prts[1]}:{float(end_time_prts[2]):.3f}".replace('.', ',')
|
83 |
print(f"RECOGNISING LINE_{i} T_START {start_time_srt} T_END {end_time_srt}")
|
|
|
6 |
import torch
|
7 |
from pydub import AudioSegment
|
8 |
from pydub.playback import play
|
9 |
+
from datetime import datetime, timedelta
|
10 |
import time
|
11 |
from silero_vad import load_silero_vad, read_audio, get_speech_timestamps
|
12 |
|
|
|
50 |
if line.strip() != "":
|
51 |
res = line.split(" ")
|
52 |
start = int(float(res[0]) * sr)
|
53 |
+
start_time = str(datetime.fromtimestamp(start / sr) - timedelta(hours=1, minutes=0)).split()[1]
|
54 |
start_time_prts = start_time.split(":")
|
55 |
start_time_srt = f"{start_time_prts[0]}:{start_time_prts[1]}:{float(start_time_prts[2]):.3f}".replace('.', ',')
|
56 |
end = int(float(res[1]) * sr)
|
57 |
+
end_time = str(datetime.fromtimestamp(end / sr) - timedelta(hours=1, minutes=0)).split()[1]
|
58 |
end_time_prts = end_time.split(":")
|
59 |
end_time_srt = f"{end_time_prts[0]}:{end_time_prts[1]}:{float(end_time_prts[2]):.3f}".replace('.', ',')
|
60 |
label = res[2]
|
|
|
72 |
for i, line in enumerate(speech_timestamps):
|
73 |
start = line['start']
|
74 |
print(start)
|
75 |
+
start_time = str(datetime.fromtimestamp(start / sr) - timedelta(hours=1, minutes=0)).split()[1]
|
76 |
start_time_prts = start_time.split(":")
|
77 |
start_time_srt = f"{start_time_prts[0]}:{start_time_prts[1]}:{float(start_time_prts[2]):.3f}".replace('.', ',')
|
78 |
print(start_time_srt)
|
79 |
end = line['end']
|
80 |
+
end_time = str(datetime.fromtimestamp(end / sr) - timedelta(hours=1, minutes=0)).split()[1]
|
81 |
end_time_prts = end_time.split(":")
|
82 |
end_time_srt = f"{end_time_prts[0]}:{end_time_prts[1]}:{float(end_time_prts[2]):.3f}".replace('.', ',')
|
83 |
print(f"RECOGNISING LINE_{i} T_START {start_time_srt} T_END {end_time_srt}")
|