smjain commited on
Commit
19d9877
1 Parent(s): 7574a38

Upload infertest.py

Browse files
Files changed (1) hide show
  1. infertest.py +17 -2
infertest.py CHANGED
@@ -15,6 +15,8 @@ from datetime import datetime
15
  from urllib.parse import urlparse
16
  from mega import Mega
17
  from flask import Flask, request, jsonify, send_file
 
 
18
  import os
19
  app = Flask(__name__)
20
 
@@ -102,13 +104,26 @@ def clean():
102
  @app.route('/convert_voice', methods=['POST'])
103
  def api_convert_voice():
104
  data = request.json
 
105
  spk_id = data['spk_id']
106
- input_audio_path = data['input_audio_path']
107
  voice_transform = data['voice_transform']
 
 
 
 
 
 
 
 
 
 
 
 
108
  print(spk_id)
109
 
110
 
111
- output_path = convert_voice(spk_id, input_audio_path, voice_transform)
112
  print(output_path)
113
  if os.path.exists(output_path):
114
  return send_file(output_path, as_attachment=True)
 
15
  from urllib.parse import urlparse
16
  from mega import Mega
17
  from flask import Flask, request, jsonify, send_file
18
+ import base64
19
+ import tempfile
20
  import os
21
  app = Flask(__name__)
22
 
 
104
  @app.route('/convert_voice', methods=['POST'])
105
  def api_convert_voice():
106
  data = request.json
107
+
108
  spk_id = data['spk_id']
109
+ #input_audio_path = data['input_audio_path']
110
  voice_transform = data['voice_transform']
111
+
112
+
113
+ audio_data = data['audio'] # Base64-encoded audio data
114
+
115
+ # Decode the base64 audio
116
+ audio_bytes = base64.b64decode(audio_data)
117
+
118
+ # Create a temporary file to save the decoded audio
119
+ temp_audio_path = os.path.join(tmp, f"{spk_id}_input_audio.wav")
120
+
121
+ with open(temp_audio_path, 'wb') as temp_audio_file:
122
+ temp_audio_file.write(audio_bytes)
123
  print(spk_id)
124
 
125
 
126
+ output_path = convert_voice(spk_id, temp_audio_file, voice_transform)
127
  print(output_path)
128
  if os.path.exists(output_path):
129
  return send_file(output_path, as_attachment=True)