blasisd commited on
Commit
441c6e3
·
1 Parent(s): fda1010

Changed turn credentials' retrieval

Browse files
Files changed (1) hide show
  1. src/app.py +12 -7
src/app.py CHANGED
@@ -31,6 +31,13 @@ model = SeamlessM4Tv2Model.from_pretrained("facebook/seamless-m4t-v2-large")
31
  default_sampling_rate = 16_000
32
 
33
 
 
 
 
 
 
 
 
34
  def translate_audio(
35
  audio: tuple[int, np.ndarray], tgt_language: str
36
  ) -> tuple[int, np.ndarray]:
@@ -190,12 +197,10 @@ with gr.Blocks(
190
  modality="audio",
191
  mode="send-receive",
192
  label="Audio Stream",
193
- rtc_configuration=(
194
- get_cloudflare_turn_credentials_async if get_space() else None
 
195
  ),
196
- # server_rtc_configuration=get_cloudflare_turn_credentials(
197
- # ttl=360_000
198
- # ),
199
  )
200
 
201
  # Trigger on pause
@@ -203,7 +208,7 @@ with gr.Blocks(
203
  ReplyOnPause(translate_audio),
204
  inputs=[audio, target_lang],
205
  outputs=[audio],
206
- concurrency_limit=20 if get_space() else None,
207
  )
208
 
209
  # Sticky footer (will stay at bottom on all screen sizes)
@@ -222,4 +227,4 @@ with gr.Blocks(
222
  """
223
  )
224
 
225
- demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
 
31
  default_sampling_rate = 16_000
32
 
33
 
34
+ HF_TOKEN = os.getenv("HF_TOKEN")
35
+
36
+
37
+ async def get_credentials():
38
+ return await get_cloudflare_turn_credentials_async(hf_token=HF_TOKEN)
39
+
40
+
41
  def translate_audio(
42
  audio: tuple[int, np.ndarray], tgt_language: str
43
  ) -> tuple[int, np.ndarray]:
 
197
  modality="audio",
198
  mode="send-receive",
199
  label="Audio Stream",
200
+ rtc_configuration=get_credentials,
201
+ server_rtc_configuration=get_cloudflare_turn_credentials(
202
+ ttl=360_000
203
  ),
 
 
 
204
  )
205
 
206
  # Trigger on pause
 
208
  ReplyOnPause(translate_audio),
209
  inputs=[audio, target_lang],
210
  outputs=[audio],
211
+ # concurrency_limit=20 if get_space() else None,
212
  )
213
 
214
  # Sticky footer (will stay at bottom on all screen sizes)
 
227
  """
228
  )
229
 
230
+ demo.launch()