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

utter times

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -216,7 +216,14 @@ def predict(
216
  except requests.exceptions.RequestException as err:
217
  print('Failed to synthesize!')
218
  save_path = ''
219
- json_data = {'text': 'Failed'}
 
 
 
 
 
 
 
220
 
221
  print('server.log contents:')
222
  with open('resources/app/server.log', 'r') as f:
@@ -224,15 +231,23 @@ def predict(
224
 
225
  arpabet_html = '<h6>ARPAbet & Durations</h6>'
226
  arpabet_symbols = json_data['arpabet'].split('|')
 
227
  for symb_i in range(len(json_data['durations'])):
 
228
  if (arpabet_symbols[symb_i] == '<PAD>'):
229
  continue
230
 
231
- arpabet_html += '<strong class="arpabet" style="padding: 0 '\
232
- + str(round(float(json_data['durations'][symb_i]/2), 1))\
233
- +'em">'\
 
 
 
 
 
234
  + arpabet_symbols[symb_i]\
235
  + '</strong> '
 
236
 
237
  return [
238
  save_path,
 
216
  except requests.exceptions.RequestException as err:
217
  print('Failed to synthesize!')
218
  save_path = ''
219
+ json_data = {
220
+ 'arpabet': ['Failed'],
221
+ 'durations': [0],
222
+ 'em_anger': anger,
223
+ 'em_happy': happy,
224
+ 'em_sad': sad,
225
+ 'em_surprise': surprise,
226
+ }
227
 
228
  print('server.log contents:')
229
  with open('resources/app/server.log', 'r') as f:
 
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'])):
236
+ # skip PAD symbol
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,