rime commited on
Commit
32fc60a
·
verified ·
1 Parent(s): ecec47b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -31
app.py CHANGED
@@ -503,47 +503,31 @@ SUPERSIZED_TEXTS = SUPERSIZED
503
  MONOPOLY_TEXTS = MONOPOLY
504
  RIME_TEXTS = SCHEDULE_ME + SUPERSIZED + MONOPOLY
505
 
506
- ivr_sid_to_name = {423: 'whirlpool', 836: 'sunrise', 2653: 'butterfly', 2654: 'rainfall', 2655: 'canyon', 2656: 'jungle', 2657: 'hills', 2658: 'lake', 3525: 'wildflower', 3529: 'peak', 3535: 'river', 3537: 'leaves', 3538: 'mountain', 3541: 'sky', 3542: 'valley', 3543: 'sunset', 3544: 'waterfall', 3545: 'pond', 3548: 'beach', 3549: 'oak', 3551: 'garden', 3552: 'stream', 3554: 'forest', 3555: 'breeze', 3558: 'meadow'}
507
- PROCESSION = [423, 836, 2653, 2654, 2655, 2656, 2657, 2658, 3525, 3529, 3535, 3537, 3538, 3541, 3542, 3543, 3544, 3545, 3548, 3549, 3551, 3552, 3554, 3555, 3558]
508
- SCHEDULEME = [2653, 2654, 2655, 2657, 3525, 3529, 3537, 3545, 3549, 3551, 3552]
509
- SUPERSIZED = [3525, 3529, 3535, 3538, 3542, 3543, 3544, 3545, 3549, 3551, 3552]
510
- MONOPOLY = [2653, 2654, 2655, 2656, 2657, 2658, 3535, 3537, 3544, 3545, 3549, 3552]
511
- RIME = [423, 836, 3525, 3529, 3535, 3537, 3538, 3541, 3542, 3543, 3544, 3545, 3548, 2653, 2654, 2655, 2656, 2657, 2658, 3549, 3551, 3552, 3554, 3555, 3558]
512
 
513
  def synthesize(key, text, speakers_must, speed, request: gr.Request):
514
  print("Requesting user: ", request.username)
515
- procession_sids = PROCESSION
516
- scheduleme_sids = SCHEDULEME
517
- supersized_sids = SUPERSIZED
518
- monopoly_sids = MONOPOLY
519
- rime_sids = RIME
520
-
521
  sids_must = []
522
  sids_random = []
523
- N = 5
524
  if len(speakers_must) > 0:
525
  sids_must = [s.strip() for s in speakers_must.split(',')]
526
- if request.username == "procession":
527
- sids_random = random.choices([s for s in procession_sids if s not in sids_must], k=(N-len(sids_must)))
528
- if len(text) == 0:
529
- text = random.choice(PROCESSION_TEXTS)
530
- elif request.username == "scheduleme":
531
- sids_random = random.choices([s for s in scheduleme_sids if s not in sids_must], k=(N-len(sids_must)))
532
- if len(text) == 0:
533
- text = random.choice(SCHEDULEME_TEXTS)
534
- elif request.username == "supersized":
535
- sids_random = random.choices([s for s in supersized_sids if s not in sids_must], k=(N-len(sids_must)))
536
- if len(text) == 0:
537
- text = random.choice(SUPERSIZED_TEXTS)
538
- elif request.username == "monopoly":
539
- sids_random = random.choices([s for s in monopoly_sids if s not in sids_must], k=(N-len(sids_must)))
540
  if len(text) == 0:
541
  text = random.choice(MONOPOLY_TEXTS)
542
- elif request.username == "rime":
543
- sids_random = random.choices([s for s in rime_sids if s not in sids_must], k=(N-len(sids_must)))
 
 
544
  if len(text) == 0:
545
  text = random.choice(RIME_TEXTS)
546
- sids = sids_must + [ivr_sid_to_name[r] for r in sids_random]
 
 
547
  print(sids)
548
  headers = {"Authorization": "Api-Key {}".format(key)}
549
 
@@ -556,10 +540,11 @@ def synthesize(key, text, speakers_must, speed, request: gr.Request):
556
  }
557
  print(json_data)
558
  response = requests.post(
559
- "https://model-232ped0q.api.baseten.co/deployment/q99zr0q/predict",
560
  headers=headers,
561
  json=json_data,
562
  )
 
563
  audioContent = response.json()
564
  decode_string = base64.b64decode(audioContent)
565
  audio_name = str(i) + "_" + str(request.username) + ".wav"
@@ -587,3 +572,4 @@ gradio_app.launch(
587
  share=True,
588
  auth=[("procession", "procession"), ("scheduleme", "scheduleme"), ("supersized", "supersized"), ("monopoly", "monopoly"), ("rime", "rime")]
589
  )
 
 
503
  MONOPOLY_TEXTS = MONOPOLY
504
  RIME_TEXTS = SCHEDULE_ME + SUPERSIZED + MONOPOLY
505
 
506
+ RIME_SPEAKERS = ["marsh", "bayou", "creek", "brook", "flower", "spore", "glacier", "gulch", "alpine", "cove", "lagoon", "tundra", "steppe", "mesa", "grove", "rainforest", "moraine", "wildflower", "peak", "boulder"]
507
+ MONOPOLY_SPEAKERS = ["alexis", "audrey", "hannah", "julie", "danielle", "breanna", "jeremy", "ronnie"]
 
 
 
 
508
 
509
  def synthesize(key, text, speakers_must, speed, request: gr.Request):
510
  print("Requesting user: ", request.username)
511
+ monopoly_sids = MONOPOLY_SPEAKERS
512
+ rime_sids = RIME_SPEAKERS
 
 
 
 
513
  sids_must = []
514
  sids_random = []
 
515
  if len(speakers_must) > 0:
516
  sids_must = [s.strip() for s in speakers_must.split(',')]
517
+
518
+ N = 5
519
+ if request.username == 'monopoly':
 
 
 
 
 
 
 
 
 
 
 
520
  if len(text) == 0:
521
  text = random.choice(MONOPOLY_TEXTS)
522
+ sids_random = random.sample([s for s in MONOPOLY_SPEAKERS if s not in sids_must], k=(N-len(sids_must)))
523
+
524
+
525
+ else:
526
  if len(text) == 0:
527
  text = random.choice(RIME_TEXTS)
528
+ sids_random = random.sample([s for s in RIME_SPEAKERS if s not in sids_must], k=(N-len(sids_must)))
529
+ print(sids_random, sids_must)
530
+ sids = sids_random + sids_must
531
  print(sids)
532
  headers = {"Authorization": "Api-Key {}".format(key)}
533
 
 
540
  }
541
  print(json_data)
542
  response = requests.post(
543
+ "https://model-232ped0q.api.baseten.co/deployment/q99450q/predict",
544
  headers=headers,
545
  json=json_data,
546
  )
547
+ print(response.json())
548
  audioContent = response.json()
549
  decode_string = base64.b64decode(audioContent)
550
  audio_name = str(i) + "_" + str(request.username) + ".wav"
 
572
  share=True,
573
  auth=[("procession", "procession"), ("scheduleme", "scheduleme"), ("supersized", "supersized"), ("monopoly", "monopoly"), ("rime", "rime")]
574
  )
575
+