Spaces:
Build error
Build error
kabita-choudhary
commited on
Commit
·
e8adb19
1
Parent(s):
fdc4fd8
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization",use_auth_toke
|
|
8 |
def diarization(inp_audio):
|
9 |
diarization = pipeline(inp_audio)
|
10 |
speakertime=[]
|
|
|
11 |
# print the result
|
12 |
for turn, _, speaker in diarization.itertracks(yield_label=True):
|
13 |
details=[turn.start,turn.end,speaker]
|
@@ -15,6 +16,7 @@ def diarization(inp_audio):
|
|
15 |
#print(turn.start)
|
16 |
#print(speaker)
|
17 |
print(f"start={turn.start:.1f}s stop={turn.end:.1f}s speaker_{speaker}")
|
|
|
18 |
#print(speakertime)
|
19 |
df = pd.DataFrame(speakertime,columns=['start', 'end','speaker'])
|
20 |
text=[]
|
@@ -25,6 +27,8 @@ def diarization(inp_audio):
|
|
25 |
for i in range (df.start.count()):
|
26 |
my_file.write(df.speaker[i]+": " +df.text[i] + '\n')
|
27 |
print(open("my_file.txt","r").read())
|
|
|
|
|
28 |
|
29 |
|
30 |
def generatetext(filename,starttime,endtime):
|
|
|
8 |
def diarization(inp_audio):
|
9 |
diarization = pipeline(inp_audio)
|
10 |
speakertime=[]
|
11 |
+
output=""
|
12 |
# print the result
|
13 |
for turn, _, speaker in diarization.itertracks(yield_label=True):
|
14 |
details=[turn.start,turn.end,speaker]
|
|
|
16 |
#print(turn.start)
|
17 |
#print(speaker)
|
18 |
print(f"start={turn.start:.1f}s stop={turn.end:.1f}s speaker_{speaker}")
|
19 |
+
output=output+f"start={turn.start:.1f}s stop={turn.end:.1f}s speaker_{speaker}"+"\n"
|
20 |
#print(speakertime)
|
21 |
df = pd.DataFrame(speakertime,columns=['start', 'end','speaker'])
|
22 |
text=[]
|
|
|
27 |
for i in range (df.start.count()):
|
28 |
my_file.write(df.speaker[i]+": " +df.text[i] + '\n')
|
29 |
print(open("my_file.txt","r").read())
|
30 |
+
return output
|
31 |
+
|
32 |
|
33 |
|
34 |
def generatetext(filename,starttime,endtime):
|