Spaces:
Sleeping
Sleeping
Commit
·
2b9c901
1
Parent(s):
bf6b287
Check point 4
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ import torchaudio
|
|
10 |
from scipy.spatial.distance import cosine
|
11 |
from RealtimeSTT import AudioToTextRecorder
|
12 |
from fastapi import FastAPI, APIRouter
|
13 |
-
from fastrtc import Stream, ReplyOnPause, StreamHandler
|
14 |
import json
|
15 |
import asyncio
|
16 |
import uvicorn
|
@@ -714,6 +714,8 @@ stream = Stream(
|
|
714 |
handler=ReplyOnPause(diarization_handler),
|
715 |
modality="audio",
|
716 |
mode="send-receive",
|
|
|
|
|
717 |
ui_args={
|
718 |
"title": "Real-time Speaker Diarization",
|
719 |
"description": "Live transcription with automatic speaker identification"
|
@@ -723,12 +725,14 @@ stream = Stream(
|
|
723 |
# Main execution
|
724 |
if __name__ == "__main__":
|
725 |
import argparse
|
|
|
726 |
|
727 |
parser = argparse.ArgumentParser(description="Real-time Speaker Diarization System")
|
728 |
parser.add_argument("--mode", choices=["ui", "api", "both"], default="ui",
|
729 |
help="Run mode: FastRTC UI, API only, or both")
|
730 |
parser.add_argument("--host", default="0.0.0.0", help="Host to bind to")
|
731 |
-
parser.add_argument("--port", type=int, default=7860,
|
|
|
732 |
parser.add_argument("--api-port", type=int, default=8000, help="API port (when running both)")
|
733 |
|
734 |
args = parser.parse_args()
|
|
|
10 |
from scipy.spatial.distance import cosine
|
11 |
from RealtimeSTT import AudioToTextRecorder
|
12 |
from fastapi import FastAPI, APIRouter
|
13 |
+
from fastrtc import Stream, ReplyOnPause, StreamHandler, get_cloudflare_turn_credentials_async, get_cloudflare_turn_credentials
|
14 |
import json
|
15 |
import asyncio
|
16 |
import uvicorn
|
|
|
714 |
handler=ReplyOnPause(diarization_handler),
|
715 |
modality="audio",
|
716 |
mode="send-receive",
|
717 |
+
rtc_configuration=get_cloudflare_turn_credentials_async,
|
718 |
+
server_rtc_configuration=get_cloudflare_turn_credentials(ttl=360_000),
|
719 |
ui_args={
|
720 |
"title": "Real-time Speaker Diarization",
|
721 |
"description": "Live transcription with automatic speaker identification"
|
|
|
725 |
# Main execution
|
726 |
if __name__ == "__main__":
|
727 |
import argparse
|
728 |
+
import os
|
729 |
|
730 |
parser = argparse.ArgumentParser(description="Real-time Speaker Diarization System")
|
731 |
parser.add_argument("--mode", choices=["ui", "api", "both"], default="ui",
|
732 |
help="Run mode: FastRTC UI, API only, or both")
|
733 |
parser.add_argument("--host", default="0.0.0.0", help="Host to bind to")
|
734 |
+
parser.add_argument("--port", type=int, default=int(os.environ.get("GRADIO_SERVER_PORT", 7860)),
|
735 |
+
help="Port to bind to")
|
736 |
parser.add_argument("--api-port", type=int, default=8000, help="API port (when running both)")
|
737 |
|
738 |
args = parser.parse_args()
|