rrg92 commited on
Commit
1643c3b
1 Parent(s): 2eacf0e

Minor fix to avoid ZeroGPU pickle error due buffered binary file

Browse files
Files changed (2) hide show
  1. app.py +1 -1
  2. xtts.py +6 -0
app.py CHANGED
@@ -124,7 +124,7 @@ def FindSpeakerByName(name, speakerType):
124
 
125
 
126
  def clone_speaker(upload_file, clone_speaker_name, cloned_speaker_names):
127
- embeddings = xtts.predict_speaker(open(upload_file,"rb"))
128
  with open(os.path.join(OUTPUT, "cloned_speakers", clone_speaker_name + ".json"), "w") as fp:
129
  json.dump(embeddings, fp)
130
  cloned_speakers[clone_speaker_name] = embeddings
 
124
 
125
 
126
  def clone_speaker(upload_file, clone_speaker_name, cloned_speaker_names):
127
+ embeddings = xtts.predict_speaker(upload_file)
128
  with open(os.path.join(OUTPUT, "cloned_speakers", clone_speaker_name + ".json"), "w") as fp:
129
  json.dump(embeddings, fp)
130
  cloned_speakers[clone_speaker_name] = embeddings
xtts.py CHANGED
@@ -47,8 +47,14 @@ print("Running XTTS Server ...", flush=True)
47
 
48
 
49
  # @app.post("/clone_speaker")
 
50
  def predict_speaker(wav_file):
51
  """Compute conditioning inputs from reference audio file."""
 
 
 
 
 
52
  temp_audio_name = next(tempfile._get_candidate_names())
53
  with open(temp_audio_name, "wb") as temp, torch.inference_mode():
54
  temp.write(io.BytesIO(wav_file.read()).getbuffer())
 
47
 
48
 
49
  # @app.post("/clone_speaker")
50
+ @spaces.GPU
51
  def predict_speaker(wav_file):
52
  """Compute conditioning inputs from reference audio file."""
53
+ wav_file = src
54
+ if isinstance(wav_file, str):
55
+ wav_file = open(wav_file,"rb");
56
+
57
+
58
  temp_audio_name = next(tempfile._get_candidate_names())
59
  with open(temp_audio_name, "wb") as temp, torch.inference_mode():
60
  temp.write(io.BytesIO(wav_file.read()).getbuffer())