deleteman commited on
Commit
9451c98
1 Parent(s): a0845a9

moving things to prod and adding support for cached examples and space secrets

Browse files
Files changed (1) hide show
  1. app.py +45 -59
app.py CHANGED
@@ -3,8 +3,10 @@ import re
3
  import requests
4
  import time
5
  import tempfile
 
6
 
7
- token = "XQMy5NHKujX8nXr8YCGktED3f7DEdvzm"
 
8
 
9
 
10
 
@@ -70,6 +72,7 @@ def flattenLines(lyrics):
70
  return newValues
71
 
72
  def getPayload(index):
 
73
  match index:
74
  case 0:
75
  return {
@@ -158,10 +161,11 @@ def getPayload(index):
158
 
159
 
160
  def greet(index, lyrics):
161
- url = "https://staging-gateway-api.voicemod.net/v2/cloud/partners/ttsing"
162
- verification_url = "https://staging-gateway-api.voicemod.net/v2/cloud/partners/ttsing/"
163
 
164
  print("Calling api with "+ lyrics)
 
165
 
166
  lines = lyrics.split("\n")
167
  #newLines = flattenLines(list(map(separate_syllables, lines)))
@@ -247,76 +251,58 @@ with gr.Blocks() as demo:
247
  video = gr.Video(label="Generated output")
248
  video.style(height=300)
249
 
250
-
251
-
252
  gr.Markdown("""
253
  ## Example lyrics
254
 
255
  To make your life easier, while testing the API, you can use and modify the following lyrics for each song:
256
  """)
257
- with gr.Row():
258
- with gr.Column():
259
- gr.Markdown("""
260
- ### Dark Trap by Jerry
261
-
262
- > this is just a test
263
- > don't worry about what I say
264
- > the lyrics want to go crazy
265
- > when pushed too hard
266
- > take it easy and relax
267
- > this is moving too fast
268
- > I can help you be
269
- > a better singer
270
- """)
271
- with gr.Column():
272
- gr.Markdown("""
273
- ### Happy Birthday by Jerry
274
-
275
- > happy birthday to you
276
- > happy birthday to you!
277
- > happy birthday dear Laura
278
- > happy birthday to you!
279
- """)
280
- with gr.Column():
281
- gr.Markdown("""
282
- ### Deck the Halls by Cecilia
283
 
284
- > Deck the halls with boughs of holly
285
- > Fa la la la la, la la la la
286
- > 'Tis the season to be jolly
287
- > Fa la la la la, la la la la
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
289
- """)
290
- with gr.Column():
291
- gr.Markdown("""
292
- ### Levitate by Ed
293
-
294
- > this is just a test
295
- > don’t worry about what I say
296
- > the lyrics want to go crazy
297
- > when pushed too hard
298
- """)
299
- with gr.Column():
300
- gr.Markdown("""
301
- ### Move Your Body by Cecilia
302
-
303
- > this is just a test
304
- > don’t worry now
305
- > the lyrics will come the less you think about them
306
- > just feel the melody
307
- """)
308
-
309
-
310
-
311
  gr.Markdown("""
312
  ## Want to use this API for your project?
313
 
314
  If you'd like to use this API for your own project, request access through our [form here](https://voicemod.typeform.com/to/KqeNN6bO?typeform-source=huggingface)
315
  """)
316
-
317
 
318
  btn.click(fn=greet,
319
- inputs=[
320
  dd,
321
  lines
322
  ],
 
3
  import requests
4
  import time
5
  import tempfile
6
+ import os
7
 
8
+ token = os.environ['apikey']
9
+ API_HOST = "https://api.voicemod.net"
10
 
11
 
12
 
 
72
  return newValues
73
 
74
  def getPayload(index):
75
+ print("Getting payload for index: " + str(index))
76
  match index:
77
  case 0:
78
  return {
 
161
 
162
 
163
  def greet(index, lyrics):
164
+ url = API_HOST + "/v2/cloud/partners/ttsing"
165
+ verification_url = API_HOST + "/v2/cloud/partners/ttsing/"
166
 
167
  print("Calling api with "+ lyrics)
168
+ print("URL: " + url)
169
 
170
  lines = lyrics.split("\n")
171
  #newLines = flattenLines(list(map(separate_syllables, lines)))
 
251
  video = gr.Video(label="Generated output")
252
  video.style(height=300)
253
 
 
 
254
  gr.Markdown("""
255
  ## Example lyrics
256
 
257
  To make your life easier, while testing the API, you can use and modify the following lyrics for each song:
258
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
 
260
+ gr.Examples(fn=greet,
261
+ examples=[["Move your Body by Cecilia", """this is just a test
262
+ don’t worry now
263
+ the lyrics will come the less you think about them
264
+ just feel the melody"""
265
+ ],
266
+ ["Dark Trap by Jerry","""this is just a test
267
+ don't worry about what I say
268
+ the lyrics want to go crazy
269
+ when pushed too hard
270
+ take it easy and relax
271
+ this is moving too fast
272
+ I can help you be
273
+ a better singer"""
274
+ ],
275
+ ["Happy Birthday by Jerry","""happy birthday to you
276
+ happy birthday to you!
277
+ happy birthday dear Laura
278
+ happy birthday to you!"""] ,
279
+ ["Deck the Halls by Cecilia", """Deck the halls with boughs of holly
280
+ Fa la la la la, la la la la
281
+ 'Tis the season to be jolly
282
+ Fa la la la la, la la la la""" ],
283
+ ["Levitate by Ed", """this is just a test
284
+ don’t worry about what I say
285
+ the lyrics want to go crazy
286
+ when pushed too hard"""]
287
+
288
+ ],
289
+ inputs=[
290
+ dd,
291
+ lines
292
+ ],
293
+ outputs=video,
294
+ cache_examples=True
295
+ )
296
+
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  gr.Markdown("""
299
  ## Want to use this API for your project?
300
 
301
  If you'd like to use this API for your own project, request access through our [form here](https://voicemod.typeform.com/to/KqeNN6bO?typeform-source=huggingface)
302
  """)
 
303
 
304
  btn.click(fn=greet,
305
+ inputs=[
306
  dd,
307
  lines
308
  ],