Spaces:
Runtime error
Runtime error
salmanmapkar
commited on
Commit
•
124dbfa
1
Parent(s):
f2e18d1
Update app.py
Browse files
app.py
CHANGED
@@ -47,9 +47,9 @@ def RemoveAllFiles():
|
|
47 |
if (os.path.isfile(file)):
|
48 |
os.remove(file)
|
49 |
|
50 |
-
def
|
51 |
SPEAKER_DICT = {}
|
52 |
-
SPEAKERS = []
|
53 |
|
54 |
def GetSpeaker(sp):
|
55 |
speaker = sp
|
@@ -61,10 +61,6 @@ def Transcribe(NumberOfSpeakers, SpeakerNames="", audio="temp_audio.wav"):
|
|
61 |
else:
|
62 |
speaker = SPEAKER_DICT[sp]
|
63 |
return speaker
|
64 |
-
|
65 |
-
def GenerateSpeakerDict(sp):
|
66 |
-
global SPEAKERS
|
67 |
-
SPEAKERS = [speaker.strip() for speaker in sp.split(',')]
|
68 |
|
69 |
def millisec(timeStr):
|
70 |
spl = timeStr.split(":")
|
@@ -113,7 +109,7 @@ def Transcribe(NumberOfSpeakers, SpeakerNames="", audio="temp_audio.wav"):
|
|
113 |
return f"dz_{audio}.wav", dzList, segments
|
114 |
|
115 |
def transcribe(dz_audio):
|
116 |
-
model = whisper.load_model("
|
117 |
result = model.transcribe(dz_audio)
|
118 |
# for _ in result['segments']:
|
119 |
# print(_['start'], _['end'], _['text'])
|
@@ -140,7 +136,6 @@ def Transcribe(NumberOfSpeakers, SpeakerNames="", audio="temp_audio.wav"):
|
|
140 |
#print(f"[{dzList[i][2]}] {c[2]}")
|
141 |
return conversation, ("".join([f"{speaker} --> {text}\n" for speaker, text in conversation]))
|
142 |
|
143 |
-
GenerateSpeakerDict(SpeakerNames)
|
144 |
spacermilli, spacer = preprocess(audio)
|
145 |
dz_audio, dzList, segments = diarization(audio)
|
146 |
conversation, t_text = transcribe(dz_audio)
|
@@ -179,7 +174,7 @@ def Transcribe_V2(num_speakers, speaker_names, audio="temp_audio.wav"):
|
|
179 |
# conversation.append([GetSpeaker(segment["speaker"]), segment["text"][1:]]) # segment["speaker"] + ' ' + str(time(segment["start"])) + '\n\n'
|
180 |
# conversation[-1][1] += segment["text"][1:]
|
181 |
# return output
|
182 |
-
return ("".join([f"{speaker} --> {text}\n" for speaker, text in conversation])), conversation
|
183 |
|
184 |
def get_duration(path):
|
185 |
with contextlib.closing(wave.open(path,'r')) as f:
|
|
|
47 |
if (os.path.isfile(file)):
|
48 |
os.remove(file)
|
49 |
|
50 |
+
def Transcribe_V1(NumberOfSpeakers, SpeakerNames="", audio="temp_audio.wav"):
|
51 |
SPEAKER_DICT = {}
|
52 |
+
SPEAKERS = [speaker.strip() for speaker in SpeakerNames.split(',')]
|
53 |
|
54 |
def GetSpeaker(sp):
|
55 |
speaker = sp
|
|
|
61 |
else:
|
62 |
speaker = SPEAKER_DICT[sp]
|
63 |
return speaker
|
|
|
|
|
|
|
|
|
64 |
|
65 |
def millisec(timeStr):
|
66 |
spl = timeStr.split(":")
|
|
|
109 |
return f"dz_{audio}.wav", dzList, segments
|
110 |
|
111 |
def transcribe(dz_audio):
|
112 |
+
model = whisper.load_model("large")
|
113 |
result = model.transcribe(dz_audio)
|
114 |
# for _ in result['segments']:
|
115 |
# print(_['start'], _['end'], _['text'])
|
|
|
136 |
#print(f"[{dzList[i][2]}] {c[2]}")
|
137 |
return conversation, ("".join([f"{speaker} --> {text}\n" for speaker, text in conversation]))
|
138 |
|
|
|
139 |
spacermilli, spacer = preprocess(audio)
|
140 |
dz_audio, dzList, segments = diarization(audio)
|
141 |
conversation, t_text = transcribe(dz_audio)
|
|
|
174 |
# conversation.append([GetSpeaker(segment["speaker"]), segment["text"][1:]]) # segment["speaker"] + ' ' + str(time(segment["start"])) + '\n\n'
|
175 |
# conversation[-1][1] += segment["text"][1:]
|
176 |
# return output
|
177 |
+
return ("".join([f"{speaker} --> {text}\n" for speaker, text in conversation])), ({ "data": [{"speaker": speaker, "text": text} for speaker, text in conversation]}))
|
178 |
|
179 |
def get_duration(path):
|
180 |
with contextlib.closing(wave.open(path,'r')) as f:
|