mrfakename commited on
Commit
5fed627
1 Parent(s): eb49710

Hopefully fixes mobile bug

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -10,6 +10,10 @@ import pyloudnorm as pyln
10
  import soundfile as sf
11
  import librosa
12
  from detoxify import Detoxify
 
 
 
 
13
  toxicity = Detoxify('original')
14
  with open('harvard_sentences.txt') as f:
15
  sents = f.read().strip().splitlines()
@@ -556,11 +560,20 @@ def synthandreturn(text):
556
  except:
557
  raise gr.Error('Unable to call API, please try again :)')
558
  print('Done with', model)
559
- result_storage[model] = result
560
  try:
561
  doresample(result)
562
  except:
563
  pass
 
 
 
 
 
 
 
 
 
 
564
  # try:
565
  # doloudnorm(result)
566
  # except:
 
10
  import soundfile as sf
11
  import librosa
12
  from detoxify import Detoxify
13
+ import os
14
+ import tempfile
15
+ from pydub import AudioSegment
16
+
17
  toxicity = Detoxify('original')
18
  with open('harvard_sentences.txt') as f:
19
  sents = f.read().strip().splitlines()
 
560
  except:
561
  raise gr.Error('Unable to call API, please try again :)')
562
  print('Done with', model)
 
563
  try:
564
  doresample(result)
565
  except:
566
  pass
567
+ try:
568
+ with tempfile.NamedTemporaryFile(suffix='.wav', delete=False) as f:
569
+ audio = AudioSegment.from_file(result)
570
+ audio.export(f.name, format="wav")
571
+ os.unlink(result)
572
+ result = f.name
573
+ except:
574
+ pass
575
+
576
+ result_storage[model] = result
577
  # try:
578
  # doloudnorm(result)
579
  # except: