thejagstudio commited on
Commit
04a96f0
·
verified ·
1 Parent(s): a84466c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +42 -0
main.py CHANGED
@@ -231,6 +231,48 @@ def index():
231
  def getAPI():
232
  return jsonify({"API": random.choice(apiKeys)})
233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
  @app.route("/api/getContext", methods=["POST"])
236
  def getContext():
 
231
  def getAPI():
232
  return jsonify({"API": random.choice(apiKeys)})
233
 
234
+ @app.route("/api/voice", methods=["POST"])
235
+ def VoiceGen():
236
+ text = request.form["text"]
237
+ url = "https://texttospeech.googleapis.com/v1beta1/text:synthesize?alt=json&key=AIzaSyBeo4NGA__U6Xxy-aBE6yFm19pgq8TY-TM"
238
+
239
+ payload = json.dumps({
240
+ "input": {
241
+ "text": text
242
+ },
243
+ "voice": {
244
+ "languageCode": "en-US",
245
+ "name": "en-US-Studio-O"
246
+ },
247
+ "audioConfig": {
248
+ "audioEncoding": "LINEAR16",
249
+ "pitch": 0,
250
+ "speakingRate": 1,
251
+ "effectsProfileId": [
252
+ "small-bluetooth-speaker-class-device"
253
+ ]
254
+ }
255
+ })
256
+ headers = {
257
+ 'sec-ch-ua': '"Google Chrome";v="123" "Not:A-Brand";v="8" "Chromium";v="123"',
258
+ 'X-Goog-Encode-Response-If-Executable': 'base64',
259
+ 'X-Origin': 'https://explorer.apis.google.com',
260
+ 'sec-ch-ua-mobile': '?0',
261
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/123.0.0.0 Safari/537.36',
262
+ 'Content-Type': 'application/json',
263
+ 'X-Requested-With': 'XMLHttpRequest',
264
+ 'X-JavaScript-User-Agent': 'apix/3.0.0 google-api-javascript-client/1.1.0',
265
+ 'X-Referer': 'https://explorer.apis.google.com',
266
+ 'sec-ch-ua-platform': '"Windows"',
267
+ 'Accept': '*/*',
268
+ 'Sec-Fetch-Site': 'same-origin',
269
+ 'Sec-Fetch-Mode': 'cors',
270
+ 'Sec-Fetch-Dest': 'empty'
271
+ }
272
+
273
+ response = requests.request("POST", url, headers=headers, data=payload)
274
+ return jsonify({"audio": response.json()["audioContent"]})
275
+
276
 
277
  @app.route("/api/getContext", methods=["POST"])
278
  def getContext():