Pendrokar commited on
Commit
f4f5edf
β€’
1 Parent(s): 1ae721a

Send back JSON as last param

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -216,6 +216,7 @@ def predict(
216
  except requests.exceptions.RequestException as err:
217
  print('Failed to synthesize!')
218
  save_path = ''
 
219
  json_data = {
220
  'arpabet': ['Failed'],
221
  'durations': [0],
@@ -229,7 +230,7 @@ def predict(
229
  with open('resources/app/server.log', 'r') as f:
230
  print(f.read())
231
 
232
- arpabet_html = '<h6>ARPAbet & Durations</h6>'
233
  arpabet_symbols = json_data['arpabet'].split('|')
234
  utter_time = 0
235
  for symb_i in range(len(json_data['durations'])):
@@ -237,17 +238,18 @@ def predict(
237
  if (arpabet_symbols[symb_i] == '<PAD>'):
238
  continue
239
 
240
- duration = round(float(json_data['durations'][symb_i]/2), 1)
 
241
  arpabet_html += '<strong\
242
  class="arpabet"\
243
  style="padding: 0 '\
244
- + str(duration)\
245
  +'em"'\
246
- +f" title=\"{utter_time} => {duration}\""\
247
  +'>'\
248
  + arpabet_symbols[symb_i]\
249
  + '</strong> '
250
- utter_time += duration
251
 
252
  return [
253
  save_path,
@@ -255,7 +257,8 @@ def predict(
255
  round(json_data['em_angry'][0], 2),
256
  round(json_data['em_happy'][0], 2),
257
  round(json_data['em_sad'][0], 2),
258
- round(json_data['em_surprise'][0], 2)
 
259
  ]
260
 
261
  input_textbox = gr.Textbox(
@@ -412,7 +415,9 @@ with gr.Blocks(css=".arpabet {display: inline-block; background-color: gray; bor
412
  anger_slider,
413
  happy_slider,
414
  sad_slider,
415
- surprise_slider
 
 
416
  ]
417
  )
418
 
 
216
  except requests.exceptions.RequestException as err:
217
  print('Failed to synthesize!')
218
  save_path = ''
219
+ response = {'text': '{"message": "Failed"}'}
220
  json_data = {
221
  'arpabet': ['Failed'],
222
  'durations': [0],
 
230
  with open('resources/app/server.log', 'r') as f:
231
  print(f.read())
232
 
233
+ arpabet_html = '<h6>ARPAbet & Phoneme lengths</h6>'
234
  arpabet_symbols = json_data['arpabet'].split('|')
235
  utter_time = 0
236
  for symb_i in range(len(json_data['durations'])):
 
238
  if (arpabet_symbols[symb_i] == '<PAD>'):
239
  continue
240
 
241
+ length = float(json_data['durations'][symb_i])
242
+ arpa_length = str(round(length/2, 1))
243
  arpabet_html += '<strong\
244
  class="arpabet"\
245
  style="padding: 0 '\
246
+ + str(arpa_length)\
247
  +'em"'\
248
+ +f" title=\"{utter_time} + {length}\""\
249
  +'>'\
250
  + arpabet_symbols[symb_i]\
251
  + '</strong> '
252
+ utter_time += round(length, 1)
253
 
254
  return [
255
  save_path,
 
257
  round(json_data['em_angry'][0], 2),
258
  round(json_data['em_happy'][0], 2),
259
  round(json_data['em_sad'][0], 2),
260
+ round(json_data['em_surprise'][0], 2),
261
+ response.text
262
  ]
263
 
264
  input_textbox = gr.Textbox(
 
415
  anger_slider,
416
  happy_slider,
417
  sad_slider,
418
+ surprise_slider,
419
+ # xVAServer JSON
420
+ gr.Textbox(visible=False)
421
  ]
422
  )
423