Last active
June 7, 2021 20:30
-
-
Save kuznetsov-m/46c38ca824c06cfd0de0968fd860d242 to your computer and use it in GitHub Desktop.
Тест yandex_speechkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
message = 'Я люблю Яндекс Спич кит!' | |
message = message[:5000] | |
speed = 1.3 | |
voices = ['alyss', 'jane', 'oksana', 'omazh', 'zahar', 'ermil', 'alena', 'filipp'] | |
voice = voices[6] | |
emotions = ['good', 'evil', 'neutral'] | |
emotion = emotions[0] | |
languages = ['ru-RU', 'en-US', 'tr-TR'] | |
language = languages[0] | |
url = 'https://cloud.yandex.ru/api/speechkit/tts' | |
headers = {'Host': 'cloud.yandex.ru','Connection': 'keep-alive','Content-Length': '125','Pragma': 'no-cache','Cache-Control': 'no-cache','sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"','Accept': 'application/json, text/plain, */*','x-csrf-token': '8b87dc04c1ae6839f2045b749937413cd340217d:1623091482','sec-ch-ua-mobile': '?0','User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36','Content-Type': 'application/json;charset=UTF-8','Origin': 'https://cloud.yandex.ru','Sec-Fetch-Site': 'same-origin','Sec-Fetch-Mode': 'cors','Sec-Fetch-Dest': 'empty','Referer': 'https://cloud.yandex.ru/services/speechkit','Accept-Encoding': 'gzip, deflate, br','Accept-Language': 'ru-RU,ru;q=0.9','Cookie': 'mda=0; yandex_gid=213; yandexuid=7458374181622908638; yuidss=7458374181622908638; is_gdpr=0; is_gdpr_b=CKfTFRDKMigC; ymex=1938268638.yrts.1622908638; my=YwA=; gdpr=0; _ym_uid=1622908639466973995; Session_id=3:1622908720.5.0.1622908720695:j2mzWQ:87.1|571422189.0.2|235599.614672.xMbfMGSAaEtBQQlrNywPdJexvdQ; sessionid2=3:1622908720.5.0.1622908720695:j2mzWQ:87.1|571422189.0.2|235599.614672.xMbfMGSAaEtBQQlrNywPdJexvdQ; ys=udn.cDphaHVuZG92enM%3D; L=V3N9dlNWUwMHVANvaVJYY0NyUFtiYnxxVCobFgMmQg4k.1622908720.14623.324596.741709dc6843eb8161818e61bd852165; yandex_login=ahundovzs; _ym_d=1622908721; i=zi1O1XWbegScMfVMoRmgRwawD4yfeBFXHZJP/b5T5KwC5YDMnc6yZ9UBnruLpLJoDV+auklpfBxL9Oo4zq8CuGgKGdU=; yabs-frequency=/5/0000000000000000/ZWvpS9G0000qGI4sSK5jXW0003H19m0DSt2K0000D44XWc51ROO0000qGICa841jXW0003H18G00/; yp=1625500638.ygu.1#1938268720.udn.cDphaHVuZG92enM%3D#1638676724.szm.1:1920x1080:1872x978#1625587130.csc.1; session-geo-data=eyJyZWdpb25OYW1lIjoi0JzQvtGB0LrQstCwINC4INCc0L7RgdC60L7QstGB0LrQsNGPINC%2B0LHQu9Cw0YHRgtGMIiwiY291bnRyeU5hbWUiOiLQoNC%2B0YHRgdC40Y8iLCJ0aW1lem9uZSI6IkV1cm9wZS9Nb3Njb3ciLCJsb2NhbGUiOnsiY29kZSI6InJ1LVJVIiwibmFtZSI6ItCg0L7RgdGB0LjRjyAo0KDRg9GB0YHQutC40LkpIiwibGFuZyI6InJ1IiwibGFuZ05hbWUiOiLQoNGD0YHRgdC60LjQuSIsInJlZ2lvbiI6InJ1IiwicmVnaW9uTmFtZSI6ItCg0L7RgdGB0LjRjyIsImN1cnJlbmN5IjoiUlVCIiwidGxkIjoicnUiLCJvcmRlciI6MX19; snout_ui_experiment=yes; cycada=be0n+eqs6WnpCacII2J550IQEEhxrkJQ1Cjb0okVUd0=; _ym_isad=2; _ym_visorc=w; XSRF-TOKEN=:D'} | |
body = f'{{"message":"{message}","language":"{language}","speed":{speed},"voice":"{voice}","emotion":"{emotion}","format":"oggopus"}}' | |
req = requests.post(url, headers=headers, data=body.encode('utf-8')) | |
print(req.status_code) | |
f = open('test.ogg', 'wb') | |
f.write(req.content) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment