Package: tinkoff-voicekit-client
Tinkoff PythonVoiceKitAPI LibraryUsageInstall fromPyPipipinstalltinkoff-voicekit-clientCommonBefore using you must haveAPI_KEYandSECRET_KEY. You can get the keys by leaving a request on ourwebsite.DocumentationType schemaExamples of usingVoiceKitclient:Recognition examplesSynthesize examplesOperation examplesUploader examplesCall documentation for public methodsfromtinkoff_voicekit_clientimportClientSTTAPI_KEY="my_api_key"SECRET_KEY="my_secret_key"client=ClientSTT(API_KEY,SECRET_KEY)client.something_method.__doc__Methods initialize using config (Python dict) which satisfies one of the next json schema.Recogniton (STT)Example of using STTrecognizefromtinkoff_voicekit_clientimportClientSTTAPI_KEY="my_api_key"SECRET_KEY="my_secret_key"client=ClientSTT(API_KEY,SECRET_KEY)audio_config={"encoding":"LINEAR16","sample_rate_hertz":8000,"num_channels":1}# recognise method callresponse=client.recognize("path/to/audio/file",audio_config)print(response)streaming recognizefromtinkoff_voicekit_clientimportClientSTTAPI_KEY="my_api_key"SECRET_KEY="my_secret_key"client=ClientSTT(API_KEY,SECRET_KEY)audio_config={"encoding":"LINEAR16","sample_rate_hertz":8000,"num_channels":1}stream_config={"config":audio_config}# recognise stream method callwithopen("path/to/audio/file","rb")assource:responses=client.streaming_recognize(source,stream_config)forresponseinresponses:print(response)long running recognize with uploaderfromtinkoff_voicekit_clientimportClientSTTAPI_KEY="my_api_key"SECRET_KEY="my_secret_key"client=ClientSTT(API_KEY,SECRET_KEY)audio_config={"encoding":"LINEAR16","sample_rate_hertz":8000,"num_channels":1}request={"config":audio_config,"group":"group_name"}file_path="path/to/file"audio_name_for_storage="pretty name"# this method automatically upload audio to long running storage and return uriprint(client.longrunning_recognize_with_uploader(file_path,request,audio_name_for_storage))Example ofVoice Activity Detectionconfigurationvad={}vad["min_speech_duration"]=min_speech_durationvad["max_speech_duration"]=max_speech_durationvad["silence_duration_threshold"]=silence_duration_thresholdvad["silence_prob_threshold"]=silence_prob_thresholdvad["aggressiveness"]=aggressivenessmy_config={}my_config["vad"]=vadSynthesize (TTS)Example of input file:Я жду вашего ответа. Вы готовы сделать перевод?
# Давайте уточним получателя. Как его зовут?commented lines # will not be synthesisExample of using TTSdefaultfromtinkoff_voicekit_clientimportClientTTSAPI_KEY="api_key"SECRET_KEY="secret_key"client=ClientTTS(API_KEY,SECRET_KEY)audio_config={"audio_encoding":"LINEAR16","sample_rate_hertz":48000}# use it if you want work with proto results# audio filerows_responses=client.streaming_synthesize("path/to/file/with/text",audio_config)# textrows_responses=client.streaming_synthesize("Мой красивый текст",audio_config)# use it if you want get audio file results# audio fileclient.synthesize_to_audio_wav("path/to/file/with/text",audio_config,"output/dir")# textclient.synthesize_to_audio_wav("Мой красивый текст",audio_config,"output/dir")# ssml. There are only tag <speak>client.synthesize_to_audio_wav("<speak>Мой красивый текст</speak>",audio_config,"output/dir",ssml=True)change voicefromtinkoff_voicekit_clientimportClientTTSAPI_KEY="api_key"SECRET_KEY="secret_key"client=ClientTTS(API_KEY,SECRET_KEY)config={"audio_encoding":"RAW_OPUS","sample_rate_hertz":48000,"voice":{"name":"alyona"}}client.synthesize_to_audio_wav("Приве! Меня зовут Алена.",config)Example of using Operationsget operation by idfromtinkoff_voicekit_clientimportClientOperationsAPI_KEY="my_api_key"SECRET_KEY="my_secret_key"operations=ClientOperations(API_KEY,SECRET_KEY)running_operation_id="42"print(operations.get_operation({"id":running_operation_id}))cancel operation by idfromtinkoff_voicekit_clientimportClientOperationsAPI_KEY="my_api_key"SECRET_KEY="my_secret_key"operations=ClientOperations(API_KEY,SECRET_KEY)operation_filter={"exact_id":"31"}# return empty dict on successprint(operations.cancel_operation(operation_filter))Example of using Uploaderfromtinkoff_voicekit_clientimportUploaderAPI_KEY="my_api_key"SECRET_KEY="my_secret_key"uploader=Uploader(API_KEY,SECRET_KEY)path="path/to/file"print(uploader.upload(path,"object_name"))