OUR COMPANY
Bring Your Ideas to Life
Everything that you dreamed of can be brought to life exactly at the moment when you decide to win.
import requests import json group_id = "1888563621730984177" api_key = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJHcm91cE5hbWUiOiLQmNC70YzRj9GBINCc0LXQt9C40YLQvtCyIiwiVXNlck5hbWUiOiLQmNC70YzRj9GBINCc0LXQt9C40YLQvtCyIiwiQWNjb3VudCI6IiIsIlN1YmplY3RJRCI6IjE4ODg1NjM2MjE3MzkzNzI3ODUiLCJQaG9uZSI6IiIsIkdyb3VwSUQiOiIxODg4NTYzNjIxNzMwOTg0MTc3IiwiUGFnZU5hbWUiOiIiLCJNYWlsIjoicmlwYXpoYTJAZ21haWwuY29tIiwiQ3JlYXRlVGltZSI6IjIwMjUtMDItMTAgMDI6NTM6MzEiLCJUb2tlblR5cGUiOjEsImlzcyI6Im1pbmltYXgifQ.IolI1pLWBN7EXnWi_AYYySUQusRe7Lcha41sJfP70s0t0X6XB2cGEm_9oAi4Rfy_u_P5AAZvIWjVsKJovdn9nGWa-uUoaZu7fQHA4VSKUdnS3-Ba3HRZQ_Na_-FdbHBK9H9-QmZJ1Ofi3072DhNVu9oibVo1yz9cs43q8Dpk5oPtnRsiYctN3kThSfidsKFoPcFv_FfNKLCxWyIfaqDkOIrgjTgoBxnBgARjv7o40e78MzvWq4pR-hSKr-YLrnuP09LDmCGGtGZWOOgAdCnow9V8vi5oqMEmePDBziz5bF82gd2i1-kseSYYTnw2pKrxqYqn8yf5Jz_zXT4Ln5ELhg" url = f"https://api.minimaxi.chat/v1/t2a_v2?GroupId={group_id}" payload = json.dumps({ "model": "speech-01-turbo", "text": "The real danger is not that computers start thinking like people, but that people start thinking like computers. Computers can only help us with simple tasks.", "stream": True, "voice_setting": { "voice_id": "Santa_Claus", "speed": 1, "vol": 1, "pitch": 0 }, "audio_setting": { "sample_rate": 32000, "bitrate": 128000, "format": "mp3", "channel": 1 } }) headers = { 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json' } response = requests.request("POST", url, stream=True, headers=headers, data=payload) parsed_json = json.loads(response.text) # get audio audio_value = bytes.fromhex(parsed_json['data']['audio']) with open('output.mp3', 'wb') as f: f.write(audio_value)
Let's go!
Made on
Tilda