stevenhillis commited on
Commit
5ca655a
·
1 Parent(s): 9400998

Avoid files object

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -15,16 +15,8 @@ def tts_fn(text, prompt_audio, prompt_seconds, inference_steps, inference_temper
15
  byte_io = io.BytesIO(bytes())
16
  wavfile.write(byte_io, sr, prompt_audio)
17
  prompt_audio_bytes = byte_io.read()
18
- prompt_audio = [base64.b64encode(prompt_audio_bytes).decode('utf-8')]
19
-
20
- response = requests.post(
21
- f'{base_url}',
22
- files=[('texts', ('texts', json.dumps(texts), 'application/json')), ('prompt_audio', ('prompt_audio', json.dumps(prompt_audio), 'application/json'))],
23
- params={'synthesize': 'true', 'pitch_steps': int(pitch_steps), 'soundstorm_steps': inference_steps, 'temperature': inference_temperature, 'prompt_seconds': prompt_seconds},
24
- headers={
25
- 'Authorization': f'Token {token_str}'
26
- },
27
- ).json()
28
  try:
29
  sample_rate = int(response['results'][0]['sample_rate'])
30
  audio = (np.array(response['results'][0]['audio']).transpose() / 1.414 * 32767).astype(np.int16)
 
15
  byte_io = io.BytesIO(bytes())
16
  wavfile.write(byte_io, sr, prompt_audio)
17
  prompt_audio_bytes = byte_io.read()
18
+ params={'synthesize': 'true', 'text': urllib.parse.quote(text), 'pitch_steps': int(pitch_steps), 'soundstorm_steps': inference_steps, 'temperature': inference_temperature, 'prompt_seconds': prompt_seconds}
19
+ response = requests.post(base_url, data=prompt_audio_bytes, params=params).json()
 
 
 
 
 
 
 
 
20
  try:
21
  sample_rate = int(response['results'][0]['sample_rate'])
22
  audio = (np.array(response['results'][0]['audio']).transpose() / 1.414 * 32767).astype(np.int16)