Pepguy commited on
Commit
36e2967
·
verified ·
1 Parent(s): 3e43fae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -1,15 +1,23 @@
1
 
 
2
  from pyannote.audio.pipelines import SpeakerDiarization
3
  import os
4
  from pyannote.core import Segment
5
  import torch
6
 
7
- # Load the speaker diarization model
8
- pipeline = SpeakerDiarization.from_pretrained("pyannote/speaker-diarization", use_auth_token="hf_"+os.getenv('ID'))
9
 
10
- # Apply diarization
11
- diarization = pipeline("sample.mp3")
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- # Print speaker segments
14
- for turn, _, speaker in diarization.itertracks(yield_label=True):
15
- print(f"Speaker {speaker}: {turn.start:.1f}s --> {turn.end:.1f}s")
 
1
 
2
+ from fastapi import FastAPI
3
  from pyannote.audio.pipelines import SpeakerDiarization
4
  import os
5
  from pyannote.core import Segment
6
  import torch
7
 
8
+ app = FastAPI()
 
9
 
10
+ @app.get("/")
11
+ def read_root():
12
+ # Load the speaker diarization model
13
+ pipeline = SpeakerDiarization.from_pretrained("pyannote/speaker-diarization", use_auth_token="hf_"+os.getenv('ID'))
14
+
15
+ # Apply diarization
16
+ diarization = pipeline("sample.mp3")
17
+
18
+ # Print speaker segments
19
+ for turn, _, speaker in diarization.itertracks(yield_label=True):
20
+ print(f"Speaker {speaker}: {turn.start:.1f}s --> {turn.end:.1f}s")
21
+
22
+ return {"Hello": "World!"}
23