freddyaboulton HF Staff commited on
Commit
7fccb2b
·
verified ·
1 Parent(s): 72a5090

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import numpy as np
3
+ from fastrtc import ReplyOnPause, Stream, get_hf_turn_credentials
4
+
5
+
6
+ def detection(audio: tuple[int, np.ndarray]):
7
+ # Implement any iterator that yields audio
8
+ # See "LLM Voice Chat" for a more complete example
9
+ yield audio
10
+
11
+
12
+ stream = Stream(
13
+ handler=ReplyOnPause(detection),
14
+ modality="audio",
15
+ mode="send-receive",
16
+ concurrency_limit=5,
17
+ rtc_configuration=get_hf_turn_credentials,
18
+ server_rtc_configuration=get_hf_turn_credentials(ttl=3_600 * 24 * 10),
19
+ time_limit=90,
20
+ )
21
+
22
+ if __name__ == "__main__":
23
+ stream.ui.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 8080)))