Update app.py
Browse files
app.py
CHANGED
@@ -503,47 +503,31 @@ SUPERSIZED_TEXTS = SUPERSIZED
|
|
503 |
MONOPOLY_TEXTS = MONOPOLY
|
504 |
RIME_TEXTS = SCHEDULE_ME + SUPERSIZED + MONOPOLY
|
505 |
|
506 |
-
|
507 |
-
|
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 |
-
|
516 |
-
|
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 |
-
|
527 |
-
|
528 |
-
|
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 |
-
|
543 |
-
|
|
|
|
|
544 |
if len(text) == 0:
|
545 |
text = random.choice(RIME_TEXTS)
|
546 |
-
|
|
|
|
|
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/
|
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 |
+
|