├── .github └── workflows │ └── pythonpublish.yml ├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.md ├── docs └── SCHEMA.md ├── requirements.txt ├── setup.cfg ├── setup.py ├── tests ├── __init__.py ├── audio_source │ ├── denorm.wav │ └── profanity_lexic.wav ├── conftest.py ├── test_aio_clients.py └── test_clients.py └── tinkoff_voicekit_client ├── Operations ├── __init__.py ├── aio_long_running.py ├── config_schema.py ├── helper_operations.py └── long_running.py ├── STT ├── __init__.py ├── aio_client_stt.py ├── client_stt.py ├── config_schema.py └── helper_stt.py ├── TTS ├── __init__.py ├── aio_client_tts.py ├── client_tts.py ├── config_schema.py ├── configurator_codec.py ├── helper_tts.py └── opuslibwin │ ├── libeay32.dll │ ├── libgcc_s_sjlj-1.dll │ ├── libogg-0.dll │ ├── libopusfile-0.dll │ ├── libopusfile.a │ ├── libopusfile.dll.a │ ├── libopusurl-0.dll │ ├── libopusurl.a │ ├── libopusurl.dll.a │ ├── libwinpthread-1.dll │ └── opus.dll ├── Uploader ├── __init__.py ├── aio_uploader.py └── uploader.py ├── __init__.py ├── aio_voicekit └── __init__.py └── speech_utils ├── BaseClient ├── __init__.py ├── aio_client.py └── base_client.py ├── __init__.py ├── apis ├── __init__.py └── tinkoff │ ├── __init__.py │ └── cloud │ ├── __init__.py │ ├── longrunning │ ├── __init__.py │ └── v1 │ │ ├── __init__.py │ │ ├── longrunning_pb2.py │ │ └── longrunning_pb2_grpc.py │ ├── stt │ ├── __init__.py │ └── v1 │ │ ├── __init__.py │ │ ├── stt_pb2.py │ │ └── stt_pb2_grpc.py │ └── tts │ ├── __init__.py │ └── v1 │ ├── __init__.py │ ├── tts_pb2.py │ └── tts_pb2_grpc.py ├── config_data.py ├── infrastructure.py ├── metadata.py └── user_utils.py /.github/workflows/pythonpublish.yml: -------------------------------------------------------------------------------- 1 | name: Upload Python Package 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | test: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | python-version: [ 3.6, 3.7, 3.8, 3.9 ] 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Install opus 17 | run: | 18 | sudo apt-get install -y opus-tools 19 | - name: Set up Python ${{ matrix.python-version }} 20 | uses: actions/setup-python@v2 21 | with: 22 | python-version: ${{ matrix.python-version }} 23 | - name: Install dependencies 24 | run: | 25 | python -m pip install --upgrade pip 26 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 27 | - name: Test with pytest 28 | env: 29 | VOICEKIT_API_KEY: ${{ secrets.VOICEKIT_API_KEY }} 30 | VOICEKIT_SECRET_KEY: ${{ secrets.VOICEKIT_SECRET_KEY }} 31 | run: | 32 | python setup.py test 33 | deploy: 34 | needs: test 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v1 38 | - name: Set up Python 39 | uses: actions/setup-python@v1 40 | with: 41 | python-version: '3.x' 42 | - name: Install dependencies 43 | run: | 44 | python -m pip install --upgrade pip 45 | pip install setuptools wheel twine 46 | - name: Build and publish 47 | env: 48 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 49 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 50 | run: | 51 | python setup.py sdist bdist_wheel 52 | twine upload dist/* 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | audio 3 | .idea 4 | speech_utils.egg-info 5 | dist 6 | build 7 | *.pem 8 | __pycache__/ 9 | input.txt 10 | input2.txt 11 | test.py 12 | /*.wav 13 | 14 | export_keys.sh 15 | 16 | # Byte-compiled / optimized / DLL files 17 | __pycache__/ 18 | *.py[cod] 19 | *$py.class 20 | 21 | # C extensions 22 | *.so 23 | 24 | # Distribution / packaging 25 | .Python 26 | env/ 27 | build/ 28 | develop-eggs/ 29 | dist/ 30 | downloads/ 31 | eggs/ 32 | .eggs/ 33 | lib/ 34 | lib64/ 35 | parts/ 36 | sdist/ 37 | var/ 38 | wheels/ 39 | *.egg-info/ 40 | .installed.cfg 41 | *.egg 42 | 43 | # PyInstaller 44 | # Usually these files are written by a python script from a template 45 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 46 | *.manifest 47 | *.spec 48 | 49 | # Installer logs 50 | pip-log.txt 51 | pip-delete-this-directory.txt 52 | 53 | # Unit test / coverage reports 54 | htmlcov/ 55 | .tox/ 56 | .coverage 57 | .coverage.* 58 | .cache 59 | nosetests.xml 60 | coverage.xml 61 | *.cover 62 | .hypothesis/ 63 | 64 | # Translations 65 | *.mo 66 | *.pot 67 | 68 | # Django stuff: 69 | *.log 70 | local_settings.py 71 | 72 | # Flask stuff: 73 | instance/ 74 | .webassets-cache 75 | 76 | # Scrapy stuff: 77 | .scrapy 78 | 79 | # Sphinx documentation 80 | docs/_build/ 81 | 82 | # PyBuilder 83 | target/ 84 | 85 | # Jupyter Notebook 86 | .ipynb_checkpoints 87 | 88 | # pyenv 89 | .python-version 90 | 91 | # celery beat schedule file 92 | celerybeat-schedule 93 | 94 | # SageMath parsed files 95 | *.sage.py 96 | 97 | # dotenv 98 | .env 99 | 100 | # virtualenv 101 | .venv 102 | venv/ 103 | ENV/ 104 | 105 | # Spyder project settings 106 | .spyderproject 107 | .spyproject 108 | 109 | # Rope project settings 110 | .ropeproject 111 | 112 | # mkdocs documentation 113 | /site 114 | 115 | # mypy 116 | .mypy_cache/ 117 | 118 | 119 | # PyCharm 120 | .idea 121 | 122 | .vscode 123 | .DS_Store 124 | /config.yaml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include tinkoff_voicekit_client/TTS/opuslibwin/* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tinkoff Python [VoiceKit](https://voicekit.tinkoff.ru/) API Library 2 | [![Downloads](https://pepy.tech/badge/tinkoff-voicekit-client)](https://pepy.tech/project/tinkoff-voicekit-client) 3 | [![Maintainability](https://api.codeclimate.com/v1/badges/263d75fe1c9d4f2bfd1a/maintainability)](https://codeclimate.com/github/TinkoffCreditSystems/voicekit_client_python/maintainability) 4 | ![Build](https://github.com/TinkoffCreditSystems/voicekit_client_python/workflows/Upload%20Python%20Package/badge.svg) 5 | 6 | ### Usage 7 | #### Install from [PyPi](https://pypi.org/project/tinkoff-voicekit-client/) 8 | ```bash 9 | pip install tinkoff-voicekit-client 10 | ``` 11 | 12 | 13 | #### Common 14 | Before using you must have *API_KEY* and *SECRET_KEY*. You can get the keys by leaving a request on our [website](https://voicekit.tinkoff.ru/). 15 | 16 | [Documentation](https://voicekit.tinkoff.ru/docs/) 17 | 18 | [Type schema](docs/SCHEMA.md) 19 | 20 | Examples of using [VoiceKit](https://voicekit.tinkoff.ru/) client: 21 | * [Recognition examples](#example-of-using-stt) 22 | * [Synthesize examples](#synthesize-tts) 23 | * [Operation examples](#example-of-using-operations) 24 | * [Uploader examples](#example-of-using-uploader) 25 | 26 | Call documentation for public methods 27 | ```python 28 | from tinkoff_voicekit_client import ClientSTT 29 | 30 | API_KEY = "my_api_key" 31 | SECRET_KEY = "my_secret_key" 32 | 33 | client = ClientSTT(API_KEY, SECRET_KEY) 34 | 35 | client.something_method.__doc__ 36 | ``` 37 | Methods initialize using config (Python dict) which satisfies one of the next json schema. 38 | 39 | #### Recogniton (STT) 40 | ##### Example of using STT 41 | * recognize 42 | ```python 43 | from tinkoff_voicekit_client import ClientSTT 44 | 45 | API_KEY = "my_api_key" 46 | SECRET_KEY = "my_secret_key" 47 | 48 | client = ClientSTT(API_KEY, SECRET_KEY) 49 | 50 | audio_config = { 51 | "encoding": "LINEAR16", 52 | "sample_rate_hertz": 8000, 53 | "num_channels": 1 54 | } 55 | 56 | # recognise method call 57 | response = client.recognize("path/to/audio/file", audio_config) 58 | print(response) 59 | ``` 60 | * streaming recognize 61 | ```python 62 | from tinkoff_voicekit_client import ClientSTT 63 | 64 | API_KEY = "my_api_key" 65 | SECRET_KEY = "my_secret_key" 66 | 67 | client = ClientSTT(API_KEY, SECRET_KEY) 68 | 69 | audio_config = { 70 | "encoding": "LINEAR16", 71 | "sample_rate_hertz": 8000, 72 | "num_channels": 1 73 | } 74 | stream_config = {"config": audio_config} 75 | 76 | # recognise stream method call 77 | with open("path/to/audio/file", "rb") as source: 78 | responses = client.streaming_recognize(source, stream_config) 79 | for response in responses: 80 | print(response) 81 | ``` 82 | * long running recognize with uploader 83 | ```python 84 | from tinkoff_voicekit_client import ClientSTT 85 | 86 | API_KEY = "my_api_key" 87 | SECRET_KEY = "my_secret_key" 88 | 89 | client = ClientSTT(API_KEY, SECRET_KEY) 90 | 91 | audio_config = { 92 | "encoding": "LINEAR16", 93 | "sample_rate_hertz": 8000, 94 | "num_channels": 1 95 | } 96 | 97 | request = { 98 | "config": audio_config, 99 | "group": "group_name" 100 | } 101 | 102 | file_path = "path/to/file" 103 | audio_name_for_storage = "pretty name" 104 | 105 | # this method automatically upload audio to long running storage and return uri 106 | print(client.longrunning_recognize_with_uploader(file_path, request, audio_name_for_storage)) 107 | ``` 108 | Example of [Voice Activity Detection](https://voicekit.tinkoff.ru/docs/stttutorial#example-customized-vad) configuration 109 | ```Python 110 | vad = {} 111 | vad["min_speech_duration"] = min_speech_duration 112 | vad["max_speech_duration"] = max_speech_duration 113 | vad["silence_duration_threshold"] = silence_duration_threshold 114 | vad["silence_prob_threshold"] = silence_prob_threshold 115 | vad["aggressiveness"] = aggressiveness 116 | 117 | my_config = {} 118 | my_config["vad"] = vad 119 | ``` 120 | 121 | #### Synthesize (TTS) 122 | Example of input file: 123 | ``` 124 | Я жду вашего ответа. Вы готовы сделать перевод? 125 | # Давайте уточним получателя. Как его зовут? 126 | ``` 127 | commented lines # will not be synthesis 128 | 129 | ##### Example of using TTS 130 | * default 131 | ```python 132 | from tinkoff_voicekit_client import ClientTTS 133 | 134 | API_KEY = "api_key" 135 | SECRET_KEY = "secret_key" 136 | 137 | client = ClientTTS(API_KEY, SECRET_KEY) 138 | audio_config = { 139 | "audio_encoding": "LINEAR16", 140 | "sample_rate_hertz": 48000 141 | } 142 | 143 | 144 | # use it if you want work with proto results 145 | # audio file 146 | rows_responses = client.streaming_synthesize("path/to/file/with/text", audio_config) 147 | # text 148 | rows_responses = client.streaming_synthesize("Мой красивый текст", audio_config) 149 | 150 | # use it if you want get audio file results 151 | # audio file 152 | client.synthesize_to_audio_wav("path/to/file/with/text", audio_config, "output/dir") 153 | # text 154 | client.synthesize_to_audio_wav("Мой красивый текст", audio_config, "output/dir") 155 | # ssml. There are only tag 156 | client.synthesize_to_audio_wav("Мой красивый текст", audio_config, "output/dir", ssml=True) 157 | ``` 158 | * change voice 159 | ```python 160 | from tinkoff_voicekit_client import ClientTTS 161 | 162 | API_KEY = "api_key" 163 | SECRET_KEY = "secret_key" 164 | 165 | client = ClientTTS(API_KEY, SECRET_KEY) 166 | config = { 167 | "audio_encoding": "RAW_OPUS", 168 | "sample_rate_hertz": 48000, 169 | "voice": {"name": "alyona"} 170 | } 171 | client.synthesize_to_audio_wav("Приве! Меня зовут Алена.", config) 172 | ``` 173 | 174 | #### Example of using Operations 175 | * get operation by id 176 | ```python 177 | from tinkoff_voicekit_client import ClientOperations 178 | API_KEY = "my_api_key" 179 | SECRET_KEY = "my_secret_key" 180 | 181 | operations = ClientOperations(API_KEY, SECRET_KEY) 182 | 183 | running_operation_id = "42" 184 | 185 | print(operations.get_operation({"id": running_operation_id})) 186 | ``` 187 | * cancel operation by id 188 | ```python 189 | from tinkoff_voicekit_client import ClientOperations 190 | API_KEY = "my_api_key" 191 | SECRET_KEY = "my_secret_key" 192 | 193 | operations = ClientOperations(API_KEY, SECRET_KEY) 194 | operation_filter = {"exact_id": "31"} 195 | 196 | # return empty dict on success 197 | print(operations.cancel_operation(operation_filter)) 198 | ``` 199 | 200 | #### Example of using Uploader 201 | ```python 202 | from tinkoff_voicekit_client import Uploader 203 | API_KEY = "my_api_key" 204 | SECRET_KEY = "my_secret_key" 205 | 206 | uploader = Uploader(API_KEY, SECRET_KEY) 207 | path = "path/to/file" 208 | 209 | print(uploader.upload(path, "object_name")) 210 | ``` -------------------------------------------------------------------------------- /docs/SCHEMA.md: -------------------------------------------------------------------------------- 1 | #### Recogniton (STT) 2 | Base types schema: 3 | ```Python 4 | definitions = { 5 | "StringArray": { 6 | "type": "array", 7 | "items": { 8 | "type": "string", 9 | } 10 | }, 11 | "AudioEncoding": { 12 | "type": "string", 13 | "enum": ["LINEAR16", "ALAW", "MULAW", "LINEAR32F", "RAW_OPUS", "MPEG_AUDIO"] 14 | }, 15 | "VoiceActivityDetectionConfig": { 16 | "type": "object", 17 | "properties": { 18 | "min_speech_duration": {"type": "number"}, 19 | "max_speech_duration": {"type": "number"}, 20 | "silence_duration_threshold": {"type": "number"}, 21 | "silence_prob_threshold": {"type": "number"}, 22 | "aggressiveness": {"type": "number"}, 23 | } 24 | }, 25 | "SpeechContext": { 26 | "type": "object", 27 | "properties": { 28 | "phrases": {"$ref": "#definitions/StringArray"}, 29 | "words": {"$ref": "#definitions/StringArray"} 30 | } 31 | }, 32 | "InterimResultsConfig": { 33 | "type": "object", 34 | "properties": { 35 | "enable_interim_results": {"type": "boolean"}, 36 | "interval": {"type": "number"} 37 | } 38 | } 39 | } 40 | ``` 41 | 42 | * Recognition config schema: 43 | ```Python 44 | recognition_config_schema = { 45 | "type": "object", 46 | "definitions": definitions, 47 | "properties": { 48 | "encoding": {"$ref": "#/definitions/AudioEncoding"}, 49 | "sample_rate_hertz": {"type": "number"}, 50 | "language_code": {"type": "string"}, 51 | "max_alternatives": {"type": "number"}, 52 | "speech_contexts": { 53 | "type": "array", 54 | "items": { 55 | "$ref": "#/definitions/SpeechContext" 56 | } 57 | }, 58 | "enable_automatic_punctuation": {"type": "boolean"}, 59 | "enable_denormalization": {"type": "boolean"}, 60 | "enable_rescoring": {"type": "boolean"}, 61 | "model": {"type": "string"}, 62 | "num_channels": {"type": "number"}, 63 | "do_not_perform_vad": {"type": "boolean"}, 64 | "vad_config": {"$ref": "#/definitions/VoiceActivityDetectionConfig"}, 65 | "profanity_filter": {"type": "boolean"} 66 | }, 67 | "required": [ 68 | "sample_rate_hertz", 69 | "num_channels", 70 | "encoding", 71 | ], 72 | "additionalProperties": False 73 | } 74 | ``` 75 | 76 | * Streaming recognition config schema: 77 | ```Python 78 | streaming_recognition_config_schema = { 79 | "type": "object", 80 | "definitions": definitions, 81 | "properties": { 82 | "config": recognition_config_schema, 83 | "single_utterance": {"type": "boolean"}, 84 | "interim_results_config": {"$ref": "#/definitions/InterimResultsConfig"} 85 | }, 86 | "additionalProperties": False 87 | } 88 | ``` 89 | 90 | * Long running recognition config schema 91 | ```python 92 | long_running_recognition_config_schema = { 93 | "type": "object", 94 | "definitions": definitions, 95 | "properties": { 96 | "config": recognition_config_schema, 97 | "group": {"type": "string"} 98 | }, 99 | "additionalProperties": False 100 | } 101 | 102 | ``` 103 | 104 | #### Synthesize (TTS) 105 | Base types schema: 106 | ```Python 107 | definitions = { 108 | "AudioEncoding": { 109 | "type": "string", 110 | "enum": ["LINEAR16", "RAW_OPUS"] 111 | }, 112 | "SynthesisInput": { 113 | "type": "object", 114 | "properties": { 115 | "text": {"type": "string"} 116 | } 117 | }, 118 | "Voice": { 119 | "type": "object", 120 | "properties": { 121 | "language_code": {"type": "string"}, 122 | "name": { 123 | "type": "string", 124 | "enum": [ 125 | "maxim", 126 | "alyona", 127 | "alyona:sad", 128 | "alyona:funny", 129 | "alyona:flirt", 130 | "dorofeev", 131 | "dorofeev:drama", 132 | "dorofeev:comedy", 133 | "dorofeev:info", 134 | "dorofeev:tragedy" 135 | ] 136 | }, 137 | "ssml_gender": { 138 | "type": "string", 139 | "enum": ["SSML_VOICE_GENDER_UNSPECIFIED", "MALE", "FEMALE", "NEUTRAL"] 140 | } 141 | } 142 | } 143 | } 144 | ``` 145 | 146 | * Streaming synthesis config schema: 147 | ```Python 148 | streaming_synthesize_config_schema = { 149 | "type": "object", 150 | "definitions": definitions, 151 | "properties": { 152 | "audio_encoding": {"$ref": "#/definitions/AudioEncoding"}, 153 | "speaking_rate": {"type": "number"}, 154 | "sample_rate_hertz": {"type": "number"} 155 | }, 156 | "required": [ 157 | "sample_rate_hertz", 158 | "audio_encoding", 159 | ], 160 | "additionalProperties": False 161 | } 162 | ``` 163 | 164 | #### Operation 165 | Base types schema: 166 | ```python 167 | definitions = { 168 | "OperationStateFilter": { 169 | "type": "string", 170 | "enum": ["ENQUEUED", "PROCESSING", "DONE", "FAILED"] 171 | }, 172 | "ServiceIDFilter": { 173 | "oneOf": [ 174 | {"exact_service_id": {"type": "string"}}, 175 | {"any_service_id": {"type": "object"}} 176 | ] 177 | }, 178 | "IDFilter": { 179 | "oneOf": [ 180 | {"exact_id": {"type": "string"}}, 181 | {"any_id": {"type": "object"}} 182 | ] 183 | }, 184 | "GroupFilter": { 185 | "oneOf": [ 186 | {"exact_group": {"type": "string"}}, 187 | {"any_group": {"type": "object"}} 188 | ] 189 | } 190 | } 191 | 192 | operation_filter_schema = { 193 | "type": "object", 194 | "definitions": definitions, 195 | "properties": { 196 | "service_id": {"$ref": "#/definitions/ServiceIDFilter"}, 197 | "id": {"$ref": "#/definitions/IDFilter"}, 198 | "group": {"$ref": "#/definitions/GroupFilter"}, 199 | "state": { 200 | "type": "array", 201 | "items": {"$ref": "#/definitions/OperationStateFilter"} 202 | }, 203 | } 204 | } 205 | ``` 206 | 207 | * List operations config schema: 208 | ```python 209 | list_operations_config_schema = { 210 | "type": "object", 211 | "operation_filter": operation_filter_schema, 212 | "properties": { 213 | "filter": {"$ref": "#/operation_filter"}, 214 | "page_size": {"type": "number"}, 215 | "page_token": {"type": "string"} 216 | } 217 | } 218 | ``` 219 | 220 | * Get operation config schema 221 | ```python 222 | get_operation_config_schema = { 223 | "type": "object", 224 | "properties": { 225 | "id": {"type": "string"} 226 | } 227 | } 228 | ``` 229 | 230 | * Wait operation config schema 231 | ```python 232 | wait_operation_config_schema = { 233 | "type": "object", 234 | "properties": { 235 | "id": {"type": "string"}, 236 | "timeout": {"type": "string"} 237 | } 238 | } 239 | ``` 240 | 241 | * Watch operation config schema 242 | ```python 243 | watch_operation_config_schema = { 244 | "type": "object", 245 | "operation_filter": operation_filter_schema, 246 | "properties": { 247 | "filter": {"$ref": "#/operation_filter_schema"}, 248 | "listen_for_updates": {"type": "boolean"} 249 | } 250 | } 251 | ``` -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | boto3>=1.12.27 2 | aioboto3~=8.3.0 3 | google>=2.0.2 4 | jsonschema>=3.0.1 5 | opuslib==3.0.1 6 | grpcio>=1.24.0 7 | grpcio_tools>=1.24.0 8 | googleapis-common-protos>=1.6.0 9 | requests>=2.21.0 10 | pytest-asyncio>=0.14.0 11 | pytest>=6.2.1 12 | setuptools>=50.3.2 -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [aliases] 2 | test=pytest 3 | 4 | [tool:pytest] 5 | addopts = -s 6 | testpaths = tests 7 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | from os.path import join, dirname 3 | 4 | version = "0.3.4" 5 | 6 | with open(join(dirname(__file__), 'README.md'), encoding='utf-8') as f: 7 | long_description = f.read() 8 | 9 | with open('requirements.txt') as fin: 10 | requirements = fin.read().splitlines() 11 | 12 | setuptools.setup( 13 | name='tinkoff_voicekit_client', 14 | version=version, 15 | license="Apache License Version 2.0", 16 | author="Tinkoff Speech Team", 17 | python_requires=">=3.6", 18 | description='Python Tinkoff Speech API', 19 | long_description=long_description, 20 | long_description_content_type='text/markdown', 21 | packages=setuptools.find_packages(), 22 | test_suite="tests", 23 | setup_requires=[ 24 | "pytest-runner", 25 | ], 26 | tests_require=[ 27 | "pytest", 28 | ], 29 | include_package_data=True, 30 | install_requires=requirements, 31 | ) 32 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tests/__init__.py -------------------------------------------------------------------------------- /tests/audio_source/denorm.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tests/audio_source/denorm.wav -------------------------------------------------------------------------------- /tests/audio_source/profanity_lexic.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tests/audio_source/profanity_lexic.wav -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | import pytest 4 | 5 | from tinkoff_voicekit_client import ClientSTT, ClientTTS, ClientOperations, aio_voicekit 6 | 7 | 8 | class ClientParams: 9 | API_KEY: str = os.getenv("VOICEKIT_API_KEY") 10 | SECRET_KEY: str = os.getenv("VOICEKIT_SECRET_KEY") 11 | 12 | 13 | @pytest.fixture 14 | def params(): 15 | if ClientParams.API_KEY is None: 16 | raise EnvironmentError("API_KEY isn't initialized") 17 | if ClientParams.SECRET_KEY is None: 18 | raise EnvironmentError("API_KEY isn't initialized") 19 | return ClientParams() 20 | 21 | 22 | @pytest.fixture 23 | def client_stt(params): 24 | return ClientSTT(params.API_KEY, params.SECRET_KEY) 25 | 26 | 27 | @pytest.fixture 28 | def client_tts(params): 29 | return ClientTTS(params.API_KEY, params.SECRET_KEY) 30 | 31 | 32 | @pytest.fixture 33 | def client_operations(params): 34 | return ClientOperations(params.API_KEY, params.SECRET_KEY) 35 | 36 | 37 | @pytest.fixture 38 | def aio_client_stt(params): 39 | return aio_voicekit.ClientSTT(params.API_KEY, params.SECRET_KEY) 40 | 41 | 42 | @pytest.fixture 43 | def aio_client_tts(params): 44 | return aio_voicekit.ClientTTS(params.API_KEY, params.SECRET_KEY) 45 | 46 | 47 | @pytest.fixture 48 | def aio_client_operations(params): 49 | return aio_voicekit.ClientOperations(params.API_KEY, params.SECRET_KEY) 50 | 51 | 52 | @pytest.fixture 53 | def audio_data(): 54 | audio_data = {} 55 | audio_data["config"] = { 56 | "encoding": "LINEAR16", 57 | "sample_rate_hertz": 48000, 58 | "num_channels": 1, 59 | } 60 | audio_data["source"] = "./tests/audio_source/denorm.wav" 61 | return audio_data 62 | 63 | 64 | @pytest.fixture 65 | def synthesis_config(): 66 | return { 67 | "audio_encoding": "RAW_OPUS", 68 | "sample_rate_hertz": 48000 69 | } 70 | 71 | @pytest.fixture 72 | def audio_with_profanity_lexic(): 73 | audio_data = {} 74 | audio_data["config"] = { 75 | "encoding": "LINEAR16", 76 | "sample_rate_hertz": 48000, 77 | "num_channels": 1, 78 | "profanity_filter": True, 79 | } 80 | audio_data["source"] = "./tests/audio_source/profanity_lexic.wav" 81 | return audio_data 82 | -------------------------------------------------------------------------------- /tests/test_aio_clients.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import pytest 4 | 5 | from tinkoff_voicekit_client import user_utils 6 | 7 | 8 | @pytest.mark.asyncio 9 | async def test_aio_recognize(aio_client_stt, audio_data): 10 | response, meta = await aio_client_stt.recognize( 11 | audio_data["source"], audio_data["config"], with_response_meta=True 12 | ) 13 | print(response) 14 | print(meta) 15 | 16 | 17 | @pytest.mark.asyncio 18 | async def test_aio_streaming_recognize(aio_client_stt, audio_data): 19 | streaming_config = {"config": audio_data["config"]} 20 | responses = await aio_client_stt.streaming_recognize( 21 | audio_data["source"], streaming_config 22 | ) 23 | async for response in responses: 24 | print(response) 25 | 26 | 27 | @pytest.mark.asyncio 28 | async def test_aio_long_running_recognize(aio_client_stt, audio_data, aio_client_operations): 29 | long_running_config = { 30 | "config": audio_data["config"], 31 | "group": "group_name" 32 | } 33 | response, uri, meta = await aio_client_stt.longrunning_recognize_with_uploader( 34 | audio_data["source"], long_running_config, with_response_meta=True 35 | ) 36 | print(response) 37 | print(uri) 38 | print(user_utils.get_x_request_id(meta)) 39 | time.sleep(1) 40 | results = await aio_client_operations.get_operation({"id": response["id"]}) 41 | print(results) 42 | 43 | 44 | @pytest.mark.asyncio 45 | async def test_aio_synthesis(aio_client_tts, synthesis_config): 46 | await aio_client_tts.synthesize_to_audio_wav("Привет, как дела!", synthesis_config, "aio_synthesis_speech") 47 | -------------------------------------------------------------------------------- /tests/test_clients.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | from tinkoff_voicekit_client import user_utils 4 | 5 | 6 | def test_recognize(client_stt, audio_data): 7 | response, meta = client_stt.recognize( 8 | audio_data["source"], audio_data["config"], with_response_meta=True 9 | ) 10 | print(response) 11 | print(user_utils.get_x_request_id(meta)) 12 | 13 | 14 | def test_streaming_recognize(client_stt, audio_data): 15 | streaming_config = {"config": audio_data["config"]} 16 | responses = client_stt.streaming_recognize( 17 | audio_data["source"], streaming_config 18 | ) 19 | for response in responses: 20 | print(response) 21 | 22 | 23 | def test_profanity_filter(client_stt, audio_with_profanity_lexic): 24 | response, meta = client_stt.recognize( 25 | audio_with_profanity_lexic["source"], 26 | audio_with_profanity_lexic["config"], 27 | with_response_meta=True, 28 | ) 29 | print(response) 30 | 31 | 32 | def test_long_running_recognize(client_stt, audio_data, client_operations): 33 | long_running_config = { 34 | "config": audio_data["config"], 35 | "group": "group_name" 36 | } 37 | response, uri, meta = client_stt.longrunning_recognize_with_uploader( 38 | audio_data["source"], long_running_config, with_response_meta=True 39 | ) 40 | print(response) 41 | print(uri) 42 | print(user_utils.get_x_request_id(meta)) 43 | time.sleep(1) 44 | results = client_operations.get_operation({"id": response["id"]}) 45 | print(results) 46 | 47 | 48 | def test_synthesis(client_tts, synthesis_config): 49 | client_tts.synthesize_to_audio_wav("Привет, как дела!", synthesis_config, "synthesis_speech") 50 | 51 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Operations/__init__.py: -------------------------------------------------------------------------------- 1 | from tinkoff_voicekit_client.Operations.long_running import ClientOperations 2 | from tinkoff_voicekit_client.Operations import aio_long_running as aio 3 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Operations/aio_long_running.py: -------------------------------------------------------------------------------- 1 | from jsonschema import validate 2 | 3 | from tinkoff_voicekit_client.Operations import config_schema 4 | from tinkoff_voicekit_client.Operations.helper_operations import ( 5 | get_proto_operation_request, 6 | get_proto_delete_operation_request, 7 | get_proto_list_operations_request, 8 | get_proto_watch_operations_request, 9 | get_proto_wait_operation_request 10 | ) 11 | from tinkoff_voicekit_client.speech_utils.BaseClient import aio_client 12 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.longrunning.v1.longrunning_pb2_grpc import OperationsStub 13 | from tinkoff_voicekit_client.speech_utils.config_data import client_config, aud 14 | from tinkoff_voicekit_client.speech_utils.infrastructure import response_format, aio_dict_generator 15 | from tinkoff_voicekit_client.speech_utils.metadata import Metadata 16 | 17 | 18 | class ClientOperations(aio_client.BaseClient): 19 | 20 | def __init__( 21 | self, 22 | api_key: str, 23 | secret_key: str, 24 | host: str = client_config["host_operations"], 25 | port: int = client_config["port"], 26 | ssl_channel: bool = True, 27 | ca_file: str = None 28 | ): 29 | """ 30 | Create async client for long running operations. 31 | :param api_key: client public api key 32 | :param secret_key: client secret api key 33 | :param host: Tinkoff Voicekit speech operations host url 34 | :param port: Tinkoff Voicekit speech operations port, default value: 443 35 | :param ca_file: optional certificate file 36 | """ 37 | super().__init__(host, port, ssl_channel, ca_file) 38 | self._metadata = Metadata(api_key, secret_key, aud["operations"]) 39 | self._api_key = api_key 40 | self._secret_key = secret_key 41 | self._stub = OperationsStub(self._channel) 42 | 43 | async def get_operation(self, request: dict, metadata=None, dict_format=True): 44 | """ 45 | Return operation by operation ID 46 | :param request: operation request 47 | :param metadata: configure own metadata 48 | :param dict_format: dict response instead of proto object 49 | """ 50 | validate(request, config_schema.get_operation_config_schema) 51 | response = await self._stub.GetOperation( 52 | get_proto_operation_request(request), 53 | metadata=metadata if metadata else self._metadata.metadata, 54 | ) 55 | return response_format(response, dict_format) 56 | 57 | async def delete_operation(self, operation_filter: dict, metadata=None, dict_format=True): 58 | """ 59 | Delete all operations matching operation filter 60 | :param operation_filter: configure operation filter 61 | :param metadata: configure own metadata 62 | :param dict_format: dict response instead of proto object 63 | """ 64 | validate(operation_filter, config_schema.operation_filter_config_schema) 65 | response = await self._stub.DeleteOperation( 66 | get_proto_delete_operation_request(operation_filter), 67 | metadata=metadata if metadata else self._metadata.metadata, 68 | ) 69 | return response_format(response, dict_format) 70 | 71 | async def cancel_operation(self, operation_filter: dict, metadata=None, dict_format=True): 72 | """ 73 | Cancel all operations matching operation filter 74 | :param operation_filter: configure operation filter 75 | :param metadata: configure own metadata 76 | :param dict_format: dict response instead of proto object 77 | """ 78 | validate(operation_filter, config_schema.operation_filter_config_schema) 79 | response = await self._stub.CancelOperation( 80 | get_proto_delete_operation_request(operation_filter), 81 | metadata=metadata if metadata else self._metadata.metadata, 82 | ) 83 | return response_format(response, dict_format) 84 | 85 | async def list_operations(self, request: dict, metadata=None, dict_format=True): 86 | """ 87 | Return list with operations 88 | :param request: configure list operation request 89 | :param metadata: configure own metadata 90 | :param dict_format: dict response instead of proto object 91 | """ 92 | validate(request, config_schema.list_operations_config_schema) 93 | response = await self._stub.ListOperations( 94 | get_proto_list_operations_request(request), 95 | metadata=metadata if metadata else self._metadata.metadata, 96 | ) 97 | return response_format(response, dict_format) 98 | 99 | async def watch_operations(self, request: dict, metadata=None, dict_format=True): 100 | """ 101 | Watch operations 102 | :param request: watch operations request 103 | :param metadata: configure own metadata 104 | :param dict_format: dict response instead of proto object 105 | """ 106 | validate(request, config_schema.watch_operations_config_schema) 107 | response = self._stub.WatchOperations( 108 | get_proto_watch_operations_request(request), 109 | metadata=metadata if metadata else self._metadata.metadata, 110 | ) 111 | return aio_dict_generator(response, dict_format) 112 | 113 | async def wait_operation(self, request: dict, metadata=None, dict_format=True): 114 | """ 115 | Wait operation 116 | :param request: wait operation request 117 | :param metadata: configure own metadata 118 | :param dict_format: dict response instead of proto object 119 | """ 120 | validate(request, config_schema.wait_operation_config_schema) 121 | response = await self._stub.WaitOperation( 122 | get_proto_wait_operation_request(request), 123 | metadata=metadata if metadata else self._metadata.metadata, 124 | ) 125 | return response_format(response, dict_format) 126 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Operations/config_schema.py: -------------------------------------------------------------------------------- 1 | definitions = { 2 | "OperationStateFilter": { 3 | "type": "string", 4 | "enum": ["ENQUEUED", "PROCESSING", "DONE", "FAILED"] 5 | }, 6 | "ServiceIDFilter": { 7 | "oneOf": [ 8 | {"exact_service_id": {"type": "string"}}, 9 | {"any_service_id": {"type": "object"}} 10 | ] 11 | }, 12 | "IDFilter": { 13 | "oneOf": [ 14 | {"exact_id": {"type": "string"}}, 15 | {"any_id": {"type": "object"}} 16 | ] 17 | }, 18 | "GroupFilter": { 19 | "oneOf": [ 20 | {"exact_group": {"type": "string"}}, 21 | {"any_group": {"type": "object"}} 22 | ] 23 | } 24 | } 25 | 26 | operation_filter_config_schema = { 27 | "type": "object", 28 | "definitions": definitions, 29 | "properties": { 30 | "service_id": {"$ref": "#/definitions/ServiceIDFilter"}, 31 | "id": {"$ref": "#/definitions/IDFilter"}, 32 | "group": {"$ref": "#/definitions/GroupFilter"}, 33 | "state": { 34 | "type": "array", 35 | "items": {"$ref": "#/definitions/OperationStateFilter"} 36 | }, 37 | } 38 | } 39 | 40 | list_operations_config_schema = { 41 | "type": "object", 42 | "operation_filter": operation_filter_config_schema, 43 | "properties": { 44 | "filter": {"$ref": "#/operation_filter"}, 45 | "page_size": {"type": "number"}, 46 | "page_token": {"type": "string"} 47 | } 48 | } 49 | 50 | get_operation_config_schema = { 51 | "type": "object", 52 | "properties": { 53 | "id": {"type": "string"} 54 | } 55 | } 56 | 57 | wait_operation_config_schema = { 58 | "type": "object", 59 | "properties": { 60 | "id": {"type": "string"}, 61 | "timeout": {"type": "string"} 62 | } 63 | } 64 | 65 | watch_operations_config_schema = { 66 | "type": "object", 67 | "operation_filter": operation_filter_config_schema, 68 | "properties": { 69 | "filter": {"$ref": "#/operation_filter"}, 70 | "listen_for_updates": {"type": "boolean"} 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Operations/helper_operations.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | from google.protobuf import json_format 4 | 5 | import tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.longrunning.v1.longrunning_pb2 as pb_operations 6 | 7 | 8 | def get_proto_operation_request(request: dict): 9 | grpc_request = json_format.Parse(json.dumps(request), pb_operations.GetOperationRequest()) 10 | return grpc_request 11 | 12 | 13 | def get_proto_delete_operation_request(operation_filter: dict): 14 | grpc_filter = json_format.Parse(json.dumps(operation_filter), pb_operations.OperationFilter()) 15 | grpc_delete_request = pb_operations.DeleteOperationRequest() 16 | grpc_delete_request.filter.CopyFrom(grpc_filter) 17 | return grpc_delete_request 18 | 19 | 20 | def get_proto_list_operations_request(request: dict): 21 | grpc_list_operation_request = json_format.Parse(json.dumps(request), pb_operations.ListOperationsRequest()) 22 | return grpc_list_operation_request 23 | 24 | 25 | def get_proto_cancel_operation_request(operation_filter: dict): 26 | grpc_filter = json_format.Parse(json.dumps(operation_filter), pb_operations.OperationFilter()) 27 | grpc_cancel_request = pb_operations.CancelOperationRequest() 28 | grpc_cancel_request.filter.CopyFrom(grpc_filter) 29 | return grpc_cancel_request 30 | 31 | 32 | def get_proto_watch_operations_request(request: dict): 33 | grpc_watch = json_format.Parse(json.dumps(request), pb_operations.WatchOperationsRequest()) 34 | return grpc_watch 35 | 36 | 37 | def get_proto_wait_operation_request(request: dict): 38 | grpc_wait = json_format.Parse(json.dumps(request), pb_operations.WaitOperationRequest()) 39 | return grpc_wait 40 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Operations/long_running.py: -------------------------------------------------------------------------------- 1 | from jsonschema import validate 2 | 3 | from tinkoff_voicekit_client.Operations import config_schema 4 | from tinkoff_voicekit_client.Operations.helper_operations import ( 5 | get_proto_operation_request, 6 | get_proto_delete_operation_request, 7 | get_proto_list_operations_request, 8 | get_proto_watch_operations_request, 9 | get_proto_wait_operation_request 10 | ) 11 | from tinkoff_voicekit_client.speech_utils.BaseClient.base_client import BaseClient 12 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.longrunning.v1.longrunning_pb2_grpc import OperationsStub 13 | from tinkoff_voicekit_client.speech_utils.config_data import client_config, aud 14 | from tinkoff_voicekit_client.speech_utils.infrastructure import response_format, dict_generator 15 | from tinkoff_voicekit_client.speech_utils.metadata import Metadata 16 | 17 | 18 | class ClientOperations(BaseClient): 19 | 20 | def __init__( 21 | self, 22 | api_key: str, 23 | secret_key: str, 24 | host: str = client_config["host_operations"], 25 | port: int = client_config["port"], 26 | ssl_channel: bool = True, 27 | ca_file: str = None 28 | ): 29 | """ 30 | Create client for long running operations. 31 | :param api_key: client public api key 32 | :param secret_key: client secret api key 33 | :param host: Tinkoff Voicekit speech operations host url 34 | :param port: Tinkoff Voicekit speech operations port, default value: 443 35 | :param ca_file: optional certificate file 36 | """ 37 | super().__init__(host, port, ssl_channel, ca_file) 38 | self._metadata = Metadata(api_key, secret_key, aud["operations"]) 39 | self._api_key = api_key 40 | self._secret_key = secret_key 41 | self._stub = OperationsStub(self._channel) 42 | 43 | def get_operation(self, request: dict, metadata=None, dict_format=True): 44 | """ 45 | Return operation by operation ID 46 | :param request: operation request 47 | :param metadata: configure own metadata 48 | :param dict_format: dict response instead of proto object 49 | """ 50 | validate(request, config_schema.get_operation_config_schema) 51 | response = self._stub.GetOperation( 52 | get_proto_operation_request(request), 53 | metadata=metadata if metadata else self._metadata.metadata, 54 | ) 55 | return response_format(response, dict_format) 56 | 57 | def delete_operation(self, operation_filter: dict, metadata=None, dict_format=True): 58 | """ 59 | Delete all operations matching operation filter 60 | :param operation_filter: configure operation filter 61 | :param metadata: configure own metadata 62 | :param dict_format: dict response instead of proto object 63 | """ 64 | validate(operation_filter, config_schema.operation_filter_config_schema) 65 | response = self._stub.DeleteOperation( 66 | get_proto_delete_operation_request(operation_filter), 67 | metadata=metadata if metadata else self._metadata.metadata, 68 | ) 69 | return response_format(response, dict_format) 70 | 71 | def cancel_operation(self, operation_filter: dict, metadata=None, dict_format=True): 72 | """ 73 | Cancel all operations matching operation filter 74 | :param operation_filter: configure operation filter 75 | :param metadata: configure own metadata 76 | :param dict_format: dict response instead of proto object 77 | """ 78 | validate(operation_filter, config_schema.operation_filter_config_schema) 79 | response = self._stub.CancelOperation( 80 | get_proto_delete_operation_request(operation_filter), 81 | metadata=metadata if metadata else self._metadata.metadata, 82 | ) 83 | return response_format(response, dict_format) 84 | 85 | def list_operations(self, request: dict, metadata=None, dict_format=True): 86 | """ 87 | Return list with operations 88 | :param request: configure list operation request 89 | :param metadata: configure own metadata 90 | :param dict_format: dict response instead of proto object 91 | """ 92 | validate(request, config_schema.list_operations_config_schema) 93 | response = self._stub.ListOperations( 94 | get_proto_list_operations_request(request), 95 | metadata=metadata if metadata else self._metadata.metadata, 96 | ) 97 | return response_format(response, dict_format) 98 | 99 | def watch_operations(self, request: dict, metadata=None, dict_format=True): 100 | """ 101 | Watch operations 102 | :param request: watch operations request 103 | :param metadata: configure own metadata 104 | :param dict_format: dict response instead of proto object 105 | """ 106 | validate(request, config_schema.watch_operations_config_schema) 107 | response = self._stub.WatchOperations( 108 | get_proto_watch_operations_request(request), 109 | metadata=metadata if metadata else self._metadata.metadata, 110 | ) 111 | return dict_generator(response, dict_format) 112 | 113 | def wait_operation(self, request: dict, metadata=None, dict_format=True): 114 | """ 115 | Wait operation 116 | :param request: wait operation request 117 | :param metadata: configure own metadata 118 | :param dict_format: dict response instead of proto object 119 | """ 120 | validate(request, config_schema.wait_operation_config_schema) 121 | response = self._stub.WaitOperation( 122 | get_proto_wait_operation_request(request), 123 | metadata=metadata if metadata else self._metadata.metadata, 124 | ) 125 | return response_format(response, dict_format) 126 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/STT/__init__.py: -------------------------------------------------------------------------------- 1 | from tinkoff_voicekit_client.STT.client_stt import ClientSTT 2 | from tinkoff_voicekit_client.STT import aio_client_stt as aio 3 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/STT/aio_client_stt.py: -------------------------------------------------------------------------------- 1 | from jsonschema import validate 2 | 3 | from tinkoff_voicekit_client.STT import config_schema 4 | from tinkoff_voicekit_client.STT.helper_stt import ( 5 | get_proto_request, 6 | get_proto_longrunning_request, 7 | create_stream_requests 8 | ) 9 | from tinkoff_voicekit_client.speech_utils.BaseClient import aio_client 10 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.stt.v1.stt_pb2_grpc import SpeechToTextStub 11 | from tinkoff_voicekit_client.speech_utils.config_data import client_config, aud 12 | from tinkoff_voicekit_client.speech_utils.infrastructure import get_buffer, aio_dict_generator, response_format 13 | from tinkoff_voicekit_client.speech_utils.metadata import Metadata 14 | from tinkoff_voicekit_client.Uploader.aio_uploader import Uploader 15 | 16 | 17 | class ClientSTT(aio_client.BaseClient): 18 | 19 | def __init__( 20 | self, 21 | api_key: str, 22 | secret_key: str, 23 | host: str = client_config["host_stt"], 24 | port: int = client_config["port"], 25 | ssl_channel: bool = True, 26 | ca_file: str = None, 27 | uploader_config: dict = None 28 | ): 29 | """ 30 | Create async client for speech recognition. 31 | :param api_key: client public api key 32 | :param secret_key: client secret api key 33 | :param host: Tinkoff Voicekit speech recognition host url 34 | :param port: Tinkoff Voicekit speech recognition port, default value: 443 35 | :param ca_file: optional certificate file 36 | :uploader_config: config for Uploader 37 | """ 38 | super().__init__(host, port, ssl_channel, ca_file) 39 | self._metadata = Metadata(api_key, secret_key, aud=aud["stt"]) 40 | self._api_key = api_key 41 | self._secret_key = secret_key 42 | self._stub = SpeechToTextStub(self._channel) 43 | 44 | uploader_config = {} if uploader_config is None else uploader_config 45 | self._uploader = Uploader(self._api_key, self._secret_key, **uploader_config) 46 | 47 | async def recognize(self, source, config, metadata=None, dict_format=True, with_response_meta=False): 48 | """ 49 | Recognize whole audio and then return all responses. 50 | :param source: path to audio file or buffer with audio 51 | :param config: dict conforming to recognition_config_schema 52 | :param dict_format: dict response instead of proto object 53 | :param with_response_meta: return response with metadata 54 | :param metadata: configure own metadata 55 | """ 56 | validate(config, config_schema.recognition_config_schema) 57 | buffer = get_buffer(source) 58 | 59 | request = self._stub.Recognize( 60 | get_proto_request(buffer, config), 61 | metadata=metadata if metadata else self._metadata.metadata 62 | ) 63 | 64 | response_meta = await request.initial_metadata() if with_response_meta else None 65 | response = await request 66 | return response_format(response, dict_format, response_meta) 67 | 68 | async def streaming_recognize( 69 | self, 70 | source, 71 | config, 72 | metadata=None, 73 | dict_format=True, 74 | with_response_meta=False, 75 | rps=20, 76 | ): 77 | """ 78 | Recognize audio in streaming mode. 79 | Stream audio chunks to server and get streaming responses. 80 | :param source: path to audio file or audio stream 81 | :param config: dict conforming to streaming_recognition_config_schema 82 | :param dict_format: dict response instead of proto object 83 | :param metadata: configure own metadata 84 | :param with_response_meta: return response with metadata 85 | :param rps: configure rps for streaming requests 86 | """ 87 | validate(config, config_schema.streaming_recognition_config_schema) 88 | buffer = get_buffer(source) 89 | 90 | responses = self._stub.StreamingRecognize( 91 | create_stream_requests(buffer, rps, config), 92 | metadata=metadata if metadata else self._metadata.metadata 93 | ) 94 | 95 | if with_response_meta: 96 | return aio_dict_generator(responses, dict_format), await responses.initial_metadata() 97 | return aio_dict_generator(responses, dict_format) 98 | 99 | async def longrunning_recognize(self, source, config, dict_format=True, metadata=None, with_response_meta=False): 100 | """ 101 | Recognize audio in long running mode. 102 | :param source: uri or buffer source 103 | :param config: dict conforming to long_running_recognition_schema 104 | :param dict_format: dict response instead of proto object 105 | :param metadata: configure own metadata 106 | :param with_response_meta: return response with metadata 107 | 108 | """ 109 | validate(config, config_schema.long_running_recognition_config_schema) 110 | if self._uploader.is_storage_uri(source): 111 | buffer = source 112 | else: 113 | buffer = get_buffer(source) 114 | 115 | request = self._stub.LongRunningRecognize( 116 | get_proto_longrunning_request(buffer, config), 117 | metadata=metadata if metadata else self._metadata.metadata 118 | ) 119 | response_meta = await request.initial_metadata() if with_response_meta else None 120 | response = await request 121 | return response_format(response, dict_format, response_meta) 122 | 123 | async def longrunning_recognize_with_uploader( 124 | self, 125 | source, 126 | config: dict, 127 | object_name: str = None, 128 | dict_format=True, metadata=None, 129 | with_response_meta=False, 130 | ): 131 | """ 132 | Recognize audio in long running mode. 133 | :param source: path to audio or fileobj 134 | :param config: dict conforming to long_running_recognition_schema 135 | :param object_name: name for object in storage (default: 'default_name_') 136 | :param dict_format: dict response instead of proto object 137 | :param metadata: configure own metadata 138 | :param with_response_meta: return response with metadata 139 | """ 140 | validate(config, config_schema.long_running_recognition_config_schema) 141 | uri = await self._uploader.upload(source, object_name) 142 | 143 | request = self._stub.LongRunningRecognize( 144 | get_proto_longrunning_request(uri, config), 145 | metadata=metadata if metadata else self._metadata.metadata 146 | ) 147 | 148 | response = await request 149 | if with_response_meta: 150 | response_meta = await request.initial_metadata() 151 | return (*response_format(response, dict_format, response_meta), uri) 152 | else: 153 | return response_format(response, dict_format), uri 154 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/STT/client_stt.py: -------------------------------------------------------------------------------- 1 | from jsonschema import validate 2 | 3 | from tinkoff_voicekit_client.STT import config_schema 4 | from tinkoff_voicekit_client.STT.helper_stt import ( 5 | get_proto_request, 6 | get_proto_longrunning_request, 7 | create_stream_requests 8 | ) 9 | from tinkoff_voicekit_client.speech_utils.BaseClient.base_client import BaseClient 10 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.stt.v1.stt_pb2_grpc import SpeechToTextStub 11 | from tinkoff_voicekit_client.speech_utils.config_data import client_config, aud 12 | from tinkoff_voicekit_client.speech_utils.infrastructure import get_buffer, dict_generator, response_format 13 | from tinkoff_voicekit_client.speech_utils.metadata import Metadata 14 | from tinkoff_voicekit_client.Uploader.uploader import Uploader 15 | 16 | 17 | class ClientSTT(BaseClient): 18 | 19 | def __init__( 20 | self, 21 | api_key: str, 22 | secret_key: str, 23 | host: str = client_config["host_stt"], 24 | port: int = client_config["port"], 25 | ssl_channel: bool = True, 26 | ca_file: str = None, 27 | uploader_config: dict = None 28 | ): 29 | """ 30 | Create client for speech recognition. 31 | :param api_key: client public api key 32 | :param secret_key: client secret api key 33 | :param host: Tinkoff Voicekit speech recognition host url 34 | :param port: Tinkoff Voicekit speech recognition port, default value: 443 35 | :param ca_file: optional certificate file 36 | :uploader_config: config for Uploader 37 | """ 38 | super().__init__(host, port, ssl_channel, ca_file) 39 | self._metadata = Metadata(api_key, secret_key, aud=aud["stt"]) 40 | self._api_key = api_key 41 | self._secret_key = secret_key 42 | self._stub = SpeechToTextStub(self._channel) 43 | 44 | uploader_config = {} if uploader_config is None else uploader_config 45 | self._uploader = Uploader(self._api_key, self._secret_key, **uploader_config) 46 | 47 | def recognize(self, source, config, metadata=None, dict_format=True, with_response_meta=False): 48 | """ 49 | Recognize whole audio and then return all responses. 50 | :param source: path to audio file or buffer with audio 51 | :param config: dict conforming to recognition_config_schema 52 | :param dict_format: dict response instead of proto object 53 | :param with_response_meta: return response with metadata 54 | :param metadata: configure own metadata 55 | """ 56 | validate(config, config_schema.recognition_config_schema) 57 | buffer = get_buffer(source) 58 | 59 | response, unary_obj = self._stub.Recognize.with_call( 60 | get_proto_request(buffer, config), 61 | metadata=metadata if metadata else self._metadata.metadata 62 | ) 63 | 64 | response_meta = unary_obj.initial_metadata() if with_response_meta else None 65 | return response_format(response, dict_format, response_meta) 66 | 67 | def streaming_recognize( 68 | self, 69 | source, 70 | config, 71 | metadata=None, 72 | dict_format=True, 73 | with_response_meta=False, 74 | rps=20, 75 | ): 76 | """ 77 | Recognize audio in streaming mode. 78 | Stream audio chunks to server and get streaming responses. 79 | :param source: path to audio file or audio stream 80 | :param config: dict conforming to streaming_recognition_config_schema 81 | :param dict_format: dict response instead of proto object 82 | :param metadata: configure own metadata 83 | :param with_response_meta: return response with metadata 84 | :param rps: configure rps for streaming requests 85 | """ 86 | validate(config, config_schema.streaming_recognition_config_schema) 87 | buffer = get_buffer(source) 88 | 89 | responses = self._stub.StreamingRecognize( 90 | create_stream_requests(buffer, rps, config), 91 | metadata=metadata if metadata else self._metadata.metadata 92 | ) 93 | 94 | if with_response_meta: 95 | return dict_generator(responses, dict_format), responses.initial_metadata() 96 | return dict_generator(responses, dict_format) 97 | 98 | def longrunning_recognize(self, source, config, dict_format=True, metadata=None, with_response_meta=False): 99 | """ 100 | Recognize audio in long running mode. 101 | :param source: uri or buffer source 102 | :param config: dict conforming to long_running_recognition_schema 103 | :param dict_format: dict response instead of proto object 104 | :param metadata: configure own metadata 105 | :param with_response_meta: return response with metadata 106 | 107 | """ 108 | validate(config, config_schema.long_running_recognition_config_schema) 109 | if self._uploader.is_storage_uri(source): 110 | buffer = source 111 | else: 112 | buffer = get_buffer(source) 113 | 114 | response, unary_obj = self._stub.LongRunningRecognize.with_call( 115 | get_proto_longrunning_request(buffer, config), 116 | metadata=metadata if metadata else self._metadata.metadata 117 | ) 118 | 119 | response_meta = unary_obj.initial_metadata() if with_response_meta else None 120 | return response_format(response, dict_format, response_meta) 121 | 122 | def longrunning_recognize_with_uploader( 123 | self, 124 | source, 125 | config: dict, 126 | object_name: str = None, 127 | dict_format=True, metadata=None, 128 | with_response_meta=False, 129 | ): 130 | """ 131 | Recognize audio in long running mode. 132 | :param source: path to audio or fileobj 133 | :param config: dict conforming to long_running_recognition_schema 134 | :param object_name: name for object in storage (default: 'default_name_') 135 | :param dict_format: dict response instead of proto object 136 | :param metadata: configure own metadata 137 | :param with_response_meta: return response with metadata 138 | """ 139 | validate(config, config_schema.long_running_recognition_config_schema) 140 | uri = self._uploader.upload(source, object_name) 141 | 142 | response, unary_obj = self._stub.LongRunningRecognize.with_call( 143 | get_proto_longrunning_request(uri, config), 144 | metadata=metadata if metadata else self._metadata.metadata 145 | ) 146 | if with_response_meta: 147 | response_meta = unary_obj.initial_metadata() 148 | return (*response_format(response, dict_format, response_meta), uri) 149 | else: 150 | return response_format(response, dict_format), uri 151 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/STT/config_schema.py: -------------------------------------------------------------------------------- 1 | definitions = { 2 | "StringArray": { 3 | "type": "array", 4 | "items": { 5 | "type": "string", 6 | } 7 | }, 8 | "AudioEncoding": { 9 | "type": "string", 10 | "enum": ["LINEAR16", "ALAW", "MULAW", "LINEAR32F", "RAW_OPUS", "MPEG_AUDIO"] 11 | }, 12 | "VoiceActivityDetectionConfig": { 13 | "type": "object", 14 | "properties": { 15 | "min_speech_duration": {"type": "number"}, 16 | "max_speech_duration": {"type": "number"}, 17 | "silence_duration_threshold": {"type": "number"}, 18 | "silence_prob_threshold": {"type": "number"}, 19 | "aggressiveness": {"type": "number"}, 20 | } 21 | }, 22 | "SpeechContext": { 23 | "type": "object", 24 | "properties": { 25 | "phrases": {"$ref": "#definitions/StringArray"}, 26 | "words": {"$ref": "#definitions/StringArray"} 27 | } 28 | }, 29 | "InterimResultsConfig": { 30 | "type": "object", 31 | "properties": { 32 | "enable_interim_results": {"type": "boolean"}, 33 | "interval": {"type": "number"} 34 | } 35 | } 36 | } 37 | 38 | recognition_config_schema = { 39 | "type": "object", 40 | "definitions": definitions, 41 | "properties": { 42 | "encoding": {"$ref": "#/definitions/AudioEncoding"}, 43 | "sample_rate_hertz": {"type": "number"}, 44 | "language_code": {"type": "string"}, 45 | "max_alternatives": {"type": "number"}, 46 | "speech_contexts": { 47 | "type": "array", 48 | "items": { 49 | "$ref": "#/definitions/SpeechContext" 50 | } 51 | }, 52 | "enable_automatic_punctuation": {"type": "boolean"}, 53 | "enable_denormalization": {"type": "boolean"}, 54 | "enable_rescoring": {"type": "boolean"}, 55 | "model": {"type": "string"}, 56 | "num_channels": {"type": "number"}, 57 | "do_not_perform_vad": {"type": "boolean"}, 58 | "vad_config": {"$ref": "#/definitions/VoiceActivityDetectionConfig"}, 59 | "profanity_filter": {"type": "boolean"} 60 | }, 61 | "required": [ 62 | "sample_rate_hertz", 63 | "num_channels", 64 | "encoding", 65 | ], 66 | "additionalProperties": False 67 | } 68 | 69 | streaming_recognition_config_schema = { 70 | "type": "object", 71 | "definitions": definitions, 72 | "properties": { 73 | "config": recognition_config_schema, 74 | "single_utterance": {"type": "boolean"}, 75 | "interim_results_config": {"$ref": "#/definitions/InterimResultsConfig"} 76 | }, 77 | "additionalProperties": False 78 | } 79 | 80 | long_running_recognition_config_schema = { 81 | "type": "object", 82 | "definitions": definitions, 83 | "properties": { 84 | "config": recognition_config_schema, 85 | "group": {"type": "string"} 86 | }, 87 | "additionalProperties": False 88 | } 89 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/STT/helper_stt.py: -------------------------------------------------------------------------------- 1 | import json 2 | import struct 3 | import time 4 | 5 | from google.protobuf import json_format 6 | 7 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.stt.v1 import stt_pb2 8 | from tinkoff_voicekit_client.speech_utils.config_data import MAX_LENGTH, CHUNK_SIZE 9 | 10 | 11 | def get_proto_request(buffer, config: dict): 12 | buffer = buffer.read() 13 | if len(buffer) > MAX_LENGTH: 14 | raise ValueError(f"Max length of file greater than max: {MAX_LENGTH}") 15 | 16 | grpc_config = json_format.Parse(json.dumps(config), stt_pb2.RecognitionConfig()) 17 | grpc_request = stt_pb2.RecognizeRequest() 18 | grpc_request.config.CopyFrom(grpc_config) 19 | grpc_request.audio.content = buffer 20 | return grpc_request 21 | 22 | 23 | def get_proto_longrunning_request(source, longrunning_config: dict): 24 | buffer = None 25 | if not isinstance(source, str): 26 | buffer = source.read() 27 | if len(buffer) > MAX_LENGTH: 28 | raise ValueError(f"Max length of file greater than max: {MAX_LENGTH}") 29 | 30 | grpc_config = json_format.Parse(json.dumps(longrunning_config["config"]), stt_pb2.RecognitionConfig()) 31 | grpc_request = stt_pb2.LongRunningRecognizeRequest() 32 | grpc_request.config.CopyFrom(grpc_config) 33 | grpc_request.group = longrunning_config.get("group", "") 34 | if buffer: 35 | grpc_request.audio.content = buffer 36 | else: 37 | grpc_request.audio.uri = source 38 | return grpc_request 39 | 40 | 41 | def get_first_stream_config(config: dict): 42 | grpc_config = json_format.Parse(json.dumps(config), stt_pb2.StreamingRecognitionConfig()) 43 | return grpc_config 44 | 45 | 46 | def create_stream_requests(buffer, rps: int, config: dict): 47 | request = stt_pb2.StreamingRecognizeRequest() 48 | request.streaming_config.CopyFrom(get_first_stream_config(config)) 49 | yield request 50 | 51 | chunk_size = CHUNK_SIZE 52 | encoding = config["config"]["encoding"] 53 | 54 | while True: 55 | if encoding == "RAW_OPUS": 56 | length_bytes = buffer.read(4) 57 | if not length_bytes: 58 | break 59 | length = struct.unpack(">I", length_bytes)[0] 60 | data = buffer.read(length) 61 | else: 62 | data = buffer.read(chunk_size) 63 | if not data: 64 | break 65 | request.audio_content = data 66 | time.sleep(1/rps) 67 | yield request 68 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/__init__.py: -------------------------------------------------------------------------------- 1 | from tinkoff_voicekit_client.TTS.client_tts import ClientTTS 2 | from tinkoff_voicekit_client.TTS import aio_client_tts as aio 3 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/aio_client_tts.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from jsonschema import validate 4 | 5 | from tinkoff_voicekit_client.TTS.configurator_codec import configuration 6 | from tinkoff_voicekit_client.TTS import config_schema 7 | from tinkoff_voicekit_client.TTS.helper_tts import ( 8 | get_utterance_generator, 9 | get_proto_synthesize_request, 10 | get_encoder, save_synthesize_wav 11 | ) 12 | from tinkoff_voicekit_client.speech_utils.BaseClient import aio_client 13 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.tts.v1.tts_pb2_grpc import TextToSpeechStub 14 | from tinkoff_voicekit_client.speech_utils.config_data import client_config, aud 15 | from tinkoff_voicekit_client.speech_utils.metadata import Metadata 16 | 17 | 18 | class ClientTTS(aio_client.BaseClient): 19 | def __init__( 20 | self, 21 | api_key: str, 22 | secret_key: str, 23 | host: str = client_config["host_tts"], 24 | port: int = client_config["port"], 25 | ssl_channel: bool = True, 26 | ca_file: str = None 27 | ): 28 | """ 29 | Create client for speech synthesis. 30 | :param api_key: client public api key 31 | :param secret_key: client secret api key 32 | :param host: Tinkoff Voicekit speech synthesize host url 33 | :param port: Tinkoff Voicekit speech synthesize port, default value: 443 34 | :param ca_file: optional certificate file 35 | """ 36 | super().__init__(host, port, ssl_channel, ca_file) 37 | configuration() 38 | self._metadata = Metadata(api_key, secret_key, aud=aud["tts"]) 39 | self._stub = TextToSpeechStub(self._channel) 40 | 41 | async def streaming_synthesize( 42 | self, 43 | text_source: str, 44 | config: dict, 45 | ssml: bool = False, 46 | text_encoding: str = "utf-8", 47 | with_response_meta=False, 48 | metadata=None 49 | ): 50 | """ 51 | Description: 52 | return generator by StreamingSynthesizeSpeechResponses from each text line in file or text string. 53 | :param text_source: path to file with text or string with text 54 | :param config: dict conforming to streaming_synthesize_config_schema 55 | :param ssml: enable ssml 56 | :param text_encoding: text encoding 57 | :param with_response_meta: return response with metadata 58 | :param metadata: configure own metadata 59 | """ 60 | validate(config, config_schema.streaming_synthesize_config_schema) 61 | request = get_proto_synthesize_request(config) 62 | 63 | utterances = get_utterance_generator(text_source, text_encoding, ssml) 64 | for synthesis_input in utterances: 65 | request.input.CopyFrom(synthesis_input) 66 | response = self._stub.StreamingSynthesize( 67 | request, metadata=metadata if metadata else self._metadata.metadata 68 | ) 69 | if with_response_meta: 70 | yield response, await response.initial_metadata() 71 | else: 72 | yield response 73 | 74 | async def synthesize_to_audio_wav( 75 | self, 76 | text_source: str, 77 | config: dict, 78 | file_name: str, 79 | ssml: bool = False, 80 | output_dir: str = os.curdir, 81 | text_encoding: str = "utf-8", 82 | with_response_meta=False, 83 | metadata=None 84 | ): 85 | """ 86 | Description: 87 | Generate audio for each text line from your text source and save it in wav format. 88 | :param text_source: path to file with text or string with text 89 | :param config: dict conforming to streaming_synthesize_config_schema 90 | :param file_name: name of synthesis audio file 91 | :param ssml: enable ssml 92 | :param output_dir: path to output directory where to store synthesized audio 93 | :param text_encoding: text encoding 94 | :param with_response_meta: return metadata of last row 95 | :param metadata: configure own metadata 96 | """ 97 | rows_responses = self.streaming_synthesize(text_source, config, ssml, text_encoding, metadata) 98 | get_chunk = get_encoder(config["audio_encoding"], config["sample_rate_hertz"]) 99 | os.makedirs(output_dir, exist_ok=True) 100 | 101 | response_meta = None 102 | index = 0 103 | async for row_response in rows_responses: 104 | response_meta = await row_response.initial_metadata() 105 | 106 | audio_chunks = [] 107 | async for response in row_response: 108 | audio_chunks += get_chunk(response.audio_chunk) 109 | 110 | save_synthesize_wav(bytes(audio_chunks), 111 | os.path.join(output_dir, f"{file_name}_{index}.wav"), 112 | config["sample_rate_hertz"]) 113 | index += 1 114 | 115 | return response_meta if with_response_meta else None 116 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/client_tts.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from jsonschema import validate 4 | 5 | from tinkoff_voicekit_client.TTS import config_schema 6 | from tinkoff_voicekit_client.TTS.configurator_codec import configuration 7 | from tinkoff_voicekit_client.TTS.helper_tts import ( 8 | get_utterance_generator, 9 | get_proto_synthesize_request, 10 | get_encoder, save_synthesize_wav 11 | ) 12 | from tinkoff_voicekit_client.speech_utils.BaseClient.base_client import BaseClient 13 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.tts.v1.tts_pb2_grpc import TextToSpeechStub 14 | from tinkoff_voicekit_client.speech_utils.config_data import client_config, aud 15 | from tinkoff_voicekit_client.speech_utils.metadata import Metadata 16 | 17 | 18 | class ClientTTS(BaseClient): 19 | def __init__( 20 | self, 21 | api_key: str, 22 | secret_key: str, 23 | host: str = client_config["host_tts"], 24 | port: int = client_config["port"], 25 | ssl_channel: bool = True, 26 | ca_file: str = None 27 | ): 28 | """ 29 | Create client for speech synthesis. 30 | :param api_key: client public api key 31 | :param secret_key: client secret api key 32 | :param host: Tinkoff Voicekit speech synthesize host url 33 | :param port: Tinkoff Voicekit speech synthesize port, default value: 443 34 | :param ca_file: optional certificate file 35 | """ 36 | super().__init__(host, port, ssl_channel, ca_file) 37 | configuration() 38 | self._metadata = Metadata(api_key, secret_key, aud=aud["tts"]) 39 | self._stub = TextToSpeechStub(self._channel) 40 | 41 | def streaming_synthesize( 42 | self, 43 | text_source: str, 44 | config: dict, 45 | ssml: bool = False, 46 | text_encoding: str = "utf-8", 47 | with_response_meta=False, 48 | metadata=None 49 | ): 50 | """ 51 | Description: 52 | return generator by StreamingSynthesizeSpeechResponses from each text line in file or text string. 53 | :param text_source: path to file with text or string with text 54 | :param config: dict conforming to streaming_synthesize_config_schema 55 | :param ssml: enable ssml 56 | :param text_encoding: text encoding 57 | :param with_response_meta: return response with metadata 58 | :param metadata: configure own metadata 59 | """ 60 | validate(config, config_schema.streaming_synthesize_config_schema) 61 | request = get_proto_synthesize_request(config) 62 | 63 | utterances = get_utterance_generator(text_source, text_encoding, ssml) 64 | for synthesis_input in utterances: 65 | request.input.CopyFrom(synthesis_input) 66 | response = self._stub.StreamingSynthesize( 67 | request, metadata=metadata if metadata else self._metadata.metadata 68 | ) 69 | if with_response_meta: 70 | yield response, response.initial_metadata() 71 | else: 72 | yield response 73 | 74 | def synthesize_to_audio_wav( 75 | self, 76 | text_source: str, 77 | config: dict, 78 | file_name: str, 79 | ssml: bool = False, 80 | output_dir: str = os.curdir, 81 | text_encoding: str = "utf-8", 82 | with_response_meta=False, 83 | metadata=None 84 | ): 85 | """ 86 | Description: 87 | Generate audio for each text line from your text source and save it in wav format. 88 | :param text_source: path to file with text or string with text 89 | :param config: dict conforming to streaming_synthesize_config_schema 90 | :param file_name: name of synthesis audio file 91 | :param ssml: enable ssml 92 | :param output_dir: path to output directory where to store synthesized audio 93 | :param text_encoding: text encoding 94 | :param with_response_meta: return metadata of last row 95 | :param metadata: configure own metadata 96 | """ 97 | rows_responses = self.streaming_synthesize(text_source, config, ssml, text_encoding, metadata) 98 | get_chunk = get_encoder(config["audio_encoding"], config["sample_rate_hertz"]) 99 | os.makedirs(output_dir, exist_ok=True) 100 | 101 | response_meta = None 102 | for index, row_response in enumerate(rows_responses): 103 | response_meta = row_response.initial_metadata() 104 | 105 | audio_chunks = [] 106 | for response in row_response: 107 | audio_chunks += get_chunk(response.audio_chunk) 108 | 109 | save_synthesize_wav(bytes(audio_chunks), 110 | os.path.join(output_dir, f"{file_name}_{index}.wav"), 111 | config["sample_rate_hertz"]) 112 | return response_meta if with_response_meta else None 113 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/config_schema.py: -------------------------------------------------------------------------------- 1 | definitions = { 2 | "AudioEncoding": { 3 | "type": "string", 4 | "enum": ["LINEAR16", "RAW_OPUS"] 5 | }, 6 | "SynthesisInput": { 7 | "type": "object", 8 | "properties": { 9 | "text": {"type": "string"}, 10 | "ssml": {"type": "string"} 11 | } 12 | }, 13 | "Voice": { 14 | "type": "object", 15 | "properties": { 16 | "language_code": {"type": "string"}, 17 | "name": { 18 | "type": "string", 19 | "enum": [ 20 | "maxim", 21 | "alyona", 22 | "alyona:sad", 23 | "alyona:funny", 24 | "alyona:flirt", 25 | "dorofeev", 26 | "dorofeev:drama", 27 | "dorofeev:comedy", 28 | "dorofeev:info", 29 | "dorofeev:tragedy" 30 | ] 31 | }, 32 | "ssml_gender": { 33 | "type": "string", 34 | "enum": ["SSML_VOICE_GENDER_UNSPECIFIED", "MALE", "FEMALE", "NEUTRAL"] 35 | } 36 | } 37 | } 38 | } 39 | 40 | streaming_synthesize_config_schema = { 41 | "type": "object", 42 | "definitions": definitions, 43 | "properties": { 44 | "audio_encoding": {"$ref": "#/definitions/AudioEncoding"}, 45 | "speaking_rate": {"type": "number"}, 46 | "sample_rate_hertz": {"type": "number"}, 47 | "voice": {"$ref": "#/definitions/Voice"} 48 | }, 49 | "required": [ 50 | "audio_encoding", 51 | "sample_rate_hertz" 52 | ], 53 | "additionalProperties": False 54 | } 55 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/configurator_codec.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | path_to_opus_lib = os.path.join(os.path.dirname(os.path.abspath(__file__)), "opuslibwin") 4 | 5 | 6 | def configuration(): 7 | if os.name == "nt" and path_to_opus_lib not in os.environ["PATH"]: 8 | os.environ["PATH"] += os.pathsep + path_to_opus_lib 9 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/helper_tts.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import wave 4 | from google.protobuf import json_format 5 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.tts.v1 import tts_pb2 6 | 7 | 8 | def get_encoder(encoding: str, rate: int): 9 | if encoding == "LINEAR16": 10 | return lambda audio_chunk: list(map(lambda x: int(x), audio_chunk)) 11 | elif encoding == "RAW_OPUS": 12 | from opuslib import Decoder 13 | decode = Decoder(rate, channels=1).decode 14 | return lambda audio_chunk: list(map(lambda x: int(x), decode(audio_chunk, frame_size=int(0.12 * rate)))) 15 | else: 16 | raise NotImplemented("Another encoding is not supported") 17 | 18 | 19 | def save_synthesize_wav( 20 | audio_content: bytes, 21 | file_name: str, 22 | rate: int, 23 | channels: int = 1 24 | ): 25 | with wave.open(file_name, "wb") as wav_out: 26 | wav_out.setnframes(len(audio_content)) 27 | wav_out.setframerate(rate) 28 | wav_out.setnchannels(channels) 29 | wav_out.setsampwidth(2) 30 | wav_out.writeframes(audio_content) 31 | 32 | 33 | def get_proto_synthesize_request(config: dict): 34 | grpc_request = tts_pb2.SynthesizeSpeechRequest() 35 | grpc_request.audio_config.audio_encoding = tts_pb2.AudioEncoding.Value(config.get("audio_encoding", 0)) 36 | grpc_request.audio_config.speaking_rate = config.get("speaking_rate", 0) 37 | grpc_request.audio_config.sample_rate_hertz = config.get("sample_rate_hertz", 0) 38 | if "voice" in config: 39 | grpc_voice_config = json_format.Parse(json.dumps(config["voice"]), tts_pb2.VoiceSelectionParams()) 40 | grpc_request.voice.CopyFrom(grpc_voice_config) 41 | return grpc_request 42 | 43 | 44 | def get_utterance_generator(text_source, text_encoding: str, enable_ssml: bool): 45 | if os.path.isfile(text_source): 46 | utterances_generator = generate_file_utterances 47 | else: 48 | utterances_generator = generate_text_utterances 49 | for text in utterances_generator(text_source, text_encoding): 50 | synthesis_input = tts_pb2.SynthesisInput() 51 | if enable_ssml: 52 | synthesis_input.ssml = text 53 | else: 54 | synthesis_input.text = text 55 | yield synthesis_input 56 | 57 | 58 | def generate_utterance(line: str): 59 | text = line.strip() 60 | return None if not text or text.startswith("#") else text 61 | 62 | 63 | def generate_file_utterances(text_file: str, text_encoding: str): 64 | with open(text_file, "r", encoding=text_encoding) as f: 65 | for line in f: 66 | result = generate_utterance(line) 67 | if result is not None: 68 | yield result 69 | 70 | 71 | def generate_text_utterances(text: str, text_encoding: str): 72 | yield text.encode(text_encoding).strip() 73 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libeay32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libeay32.dll -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libgcc_s_sjlj-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libgcc_s_sjlj-1.dll -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libogg-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libogg-0.dll -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libopusfile-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libopusfile-0.dll -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libopusfile.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libopusfile.a -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libopusfile.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libopusfile.dll.a -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libopusurl-0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libopusurl-0.dll -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libopusurl.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libopusurl.a -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libopusurl.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libopusurl.dll.a -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/libwinpthread-1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/libwinpthread-1.dll -------------------------------------------------------------------------------- /tinkoff_voicekit_client/TTS/opuslibwin/opus.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/TTS/opuslibwin/opus.dll -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Uploader/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/Uploader/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Uploader/aio_uploader.py: -------------------------------------------------------------------------------- 1 | import os 2 | import aioboto3 3 | 4 | from datetime import datetime 5 | from tinkoff_voicekit_client.Uploader.uploader import UploaderBase 6 | 7 | 8 | class Uploader(UploaderBase): 9 | def __init__(self, api_key: str, secret_key: str, ca_file: str = None, host: str = None): 10 | """ 11 | aio_voicekit Uploader upload data for Long running execution 12 | :param api_key: client public api key 13 | :param secret_key: client secret api key 14 | :param ca_file: optional certificate file 15 | :param host: Tinkoff Voicekit uploader host url 16 | """ 17 | super().__init__(api_key, secret_key, ca_file, host) 18 | self._s3 = aioboto3.client( 19 | service_name="s3", 20 | endpoint_url=self._host, 21 | aws_access_key_id=self._api_key, 22 | aws_secret_access_key=self._secret_key, 23 | verify=self._ca_file 24 | ) 25 | 26 | async def upload(self, source: str, object_name: str = None): 27 | """ 28 | async Upload data from source for long running execution 29 | uri has next schema: storage://UPLOADER_HOST/_BUCKET/ 30 | :param source: path to file or file like obj 31 | :param object_name: object name in storage (default: 'default_name_') 32 | :return: uri 33 | """ 34 | async with self._s3 as client: 35 | if object_name is None: 36 | object_name = f"default_name_{datetime.utcnow()}" 37 | if os.path.isfile(source): 38 | await client.upload_file(source, Uploader._BUCKET, object_name) 39 | else: 40 | await client.upload_fileobj(source, Uploader._BUCKET, object_name) 41 | return Uploader.create_uri(object_name) 42 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/Uploader/uploader.py: -------------------------------------------------------------------------------- 1 | import os 2 | from datetime import datetime 3 | 4 | import boto3 5 | 6 | 7 | class UploaderBase: 8 | UPLOADER_HOST = "s3.api.tinkoff.ai" 9 | STORAGE_PREFIX = "storage://" 10 | _BUCKET = "inbound" 11 | 12 | def __init__( 13 | self, 14 | api_key: str, 15 | secret_key: str, 16 | ca_file: str = None, 17 | host: str = None 18 | ): 19 | """ 20 | UploaderBase preserve params for S3 storage 21 | :param api_key: client public api key 22 | :param secret_key: client secret api key 23 | :param ca_file: optional certificate file 24 | :param host: Tinkoff Voicekit uploader host url 25 | """ 26 | self._host = "https://{0}".format(Uploader.UPLOADER_HOST) if host is None else host 27 | self._api_key = api_key 28 | self._secret_key = secret_key 29 | self._ca_file = ca_file 30 | 31 | @staticmethod 32 | def create_uri(object_name: str): 33 | return "{0}{1}/{2}/{3}".format( 34 | Uploader.STORAGE_PREFIX, 35 | Uploader.UPLOADER_HOST, 36 | Uploader._BUCKET, 37 | object_name 38 | ) 39 | 40 | @staticmethod 41 | def is_storage_uri(uri: str): 42 | """ 43 | check uri on correct header 44 | :param uri: verifiable identifier 45 | """ 46 | return isinstance(uri, str) and uri.startswith(f"{Uploader.STORAGE_PREFIX}") 47 | 48 | 49 | class Uploader(UploaderBase): 50 | def __init__(self, api_key: str, secret_key: str, ca_file: str = None, host: str = None): 51 | """ 52 | Uploader upload data for Long running execution 53 | :param api_key: client public api key 54 | :param secret_key: client secret api key 55 | :param ca_file: optional certificate file 56 | :param host: Tinkoff Voicekit uploader host url 57 | """ 58 | super().__init__(api_key, secret_key, ca_file, host) 59 | self._s3 = boto3.client( 60 | service_name="s3", 61 | endpoint_url=self._host, 62 | aws_access_key_id=self._api_key, 63 | aws_secret_access_key=self._secret_key, 64 | verify=self._ca_file 65 | ) 66 | 67 | def upload(self, source: str, object_name: str = None): 68 | """ 69 | Upload data from source for long running execution 70 | uri has next schema: storage://UPLOADER_HOST/_BUCKET/ 71 | :param source: path to file or file like obj 72 | :param object_name: object name in storage (default: 'default_name_') 73 | :return: uri 74 | """ 75 | if object_name is None: 76 | object_name = f"default_name_{datetime.utcnow()}" 77 | if os.path.isfile(source): 78 | self._s3.upload_file(source, Uploader._BUCKET, object_name) 79 | else: 80 | self._s3.upload_fileobj(source, Uploader._BUCKET, object_name) 81 | return Uploader.create_uri(object_name) 82 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/__init__.py: -------------------------------------------------------------------------------- 1 | from tinkoff_voicekit_client.STT import ClientSTT 2 | from tinkoff_voicekit_client.TTS import ClientTTS 3 | from tinkoff_voicekit_client.Operations import ClientOperations 4 | from tinkoff_voicekit_client.Uploader.uploader import Uploader 5 | from tinkoff_voicekit_client.speech_utils import user_utils 6 | from tinkoff_voicekit_client import aio_voicekit 7 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/aio_voicekit/__init__.py: -------------------------------------------------------------------------------- 1 | """AIO Clients aggregation""" 2 | from tinkoff_voicekit_client.STT.aio_client_stt import ClientSTT 3 | from tinkoff_voicekit_client.TTS.aio_client_tts import ClientTTS 4 | from tinkoff_voicekit_client.Operations.aio_long_running import ClientOperations 5 | from tinkoff_voicekit_client.Uploader.aio_uploader import Uploader 6 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/BaseClient/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/BaseClient/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/BaseClient/aio_client.py: -------------------------------------------------------------------------------- 1 | import grpc 2 | 3 | from tinkoff_voicekit_client.speech_utils.BaseClient.base_client import AbstractBaseClient 4 | 5 | 6 | class BaseClient(AbstractBaseClient): 7 | """ 8 | This class provide base methods for STT, TTS, Operations 9 | """ 10 | def __init__(self, host, port, ssl_channel=False, ca_file=None, options: list = None): 11 | super().__init__(host, port, ssl_channel, ca_file, options) 12 | 13 | def _make_channel(self): 14 | target = "{}:{}".format(self._host, self._port) 15 | if self._ssl_channel: 16 | creds = self._get_credential() 17 | return grpc.aio.secure_channel(target, creds, options=self._options) 18 | else: 19 | return grpc.aio.insecure_channel(target, options=self._options) 20 | 21 | async def close(self): 22 | await self._channel.close() 23 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/BaseClient/base_client.py: -------------------------------------------------------------------------------- 1 | import grpc 2 | 3 | from abc import ABC, abstractmethod 4 | 5 | from tinkoff_voicekit_client.speech_utils.config_data import MAX_LENGTH 6 | 7 | 8 | class AbstractBaseClient(ABC): 9 | """ 10 | This class provide abstract channel creation. 11 | _make_channel must be overridden. 12 | """ 13 | 14 | def __init__( 15 | self, 16 | host, 17 | port, 18 | ssl_channel=False, 19 | ca_file=None, 20 | options: list = None, 21 | ): 22 | self._host = host 23 | self._port = port 24 | self._ssl_channel = ssl_channel 25 | self._ca_file = ca_file 26 | self._configure_channel(options) 27 | self._channel = self._make_channel() 28 | 29 | def _configure_channel(self, options): 30 | if options: 31 | self._options = options 32 | else: 33 | self._options = [ 34 | ('grpc.max_send_message_length', MAX_LENGTH), 35 | ('grpc.max_receive_message_length', MAX_LENGTH) 36 | ] 37 | 38 | def _get_credential(self): 39 | if not self._ca_file: 40 | return grpc.ssl_channel_credentials() 41 | with open(self._ca_file, "rb") as pem: 42 | return grpc.ssl_channel_credentials(pem.read()) 43 | 44 | @abstractmethod 45 | def _make_channel(self): 46 | pass 47 | 48 | 49 | class BaseClient(AbstractBaseClient): 50 | """ 51 | This class provide base methods for STT, TTS, Operations 52 | """ 53 | def __init__(self, host, port, ssl_channel=False, ca_file=None, options: list = None): 54 | super().__init__(host, port, ssl_channel, ca_file, options) 55 | 56 | def __del__(self): 57 | if hasattr(self, "_channel"): 58 | self._channel.close() 59 | 60 | def _make_channel(self): 61 | target = "{}:{}".format(self._host, self._port) 62 | if self._ssl_channel: 63 | creds = self._get_credential() 64 | return grpc.secure_channel(target, creds, options=self._options) 65 | else: 66 | return grpc.insecure_channel(target, options=self._options) 67 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/longrunning/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/longrunning/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/longrunning/v1/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/longrunning/v1/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/longrunning/v1/longrunning_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: tinkoff/cloud/longrunning/v1/longrunning.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import enum_type_wrapper 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import message as _message 8 | from google.protobuf import reflection as _reflection 9 | from google.protobuf import symbol_database as _symbol_database 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 16 | from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 17 | from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 18 | from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 19 | from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 20 | 21 | 22 | DESCRIPTOR = _descriptor.FileDescriptor( 23 | name='tinkoff/cloud/longrunning/v1/longrunning.proto', 24 | package='tinkoff.cloud.longrunning.v1', 25 | syntax='proto3', 26 | serialized_options=b'ZHstash.tcsbank.ru/stt/tinkoff_cloud_apis/pkg/tinkoff/cloud/longrunning/v1', 27 | create_key=_descriptor._internal_create_key, 28 | serialized_pb=b'\n.tinkoff/cloud/longrunning/v1/longrunning.proto\x12\x1ctinkoff.cloud.longrunning.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x17google/rpc/status.proto\"\x81\x02\n\tOperation\x12\n\n\x02id\x18\x01 \x01(\t\x12\r\n\x05group\x18\x02 \x01(\t\x12&\n\x08metadata\x18\x03 \x01(\x0b\x32\x14.google.protobuf.Any\x12;\n\x05state\x18\x04 \x01(\x0e\x32,.tinkoff.cloud.longrunning.v1.OperationState\x12#\n\x05\x65rror\x18\x05 \x01(\x0b\x32\x12.google.rpc.StatusH\x00\x12(\n\x08response\x18\x06 \x01(\x0b\x32\x14.google.protobuf.AnyH\x00\x12\x1b\n\x13x_client_request_id\x18\x07 \x01(\tB\x08\n\x06result\"\xbb\x02\n\x0fOperationFilter\x12\x1a\n\x10\x65xact_service_id\x18\x01 \x01(\tH\x00\x12\x30\n\x0e\x61ny_service_id\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12\x12\n\x08\x65xact_id\x18\x03 \x01(\tH\x01\x12(\n\x06\x61ny_id\x18\x04 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x01\x12\x15\n\x0b\x65xact_group\x18\x05 \x01(\tH\x02\x12+\n\tany_group\x18\x06 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x02\x12;\n\x05state\x18\x07 \x03(\x0e\x32,.tinkoff.cloud.longrunning.v1.OperationStateB\x0c\n\nservice_idB\x04\n\x02idB\x07\n\x05group\"!\n\x13GetOperationRequest\x12\n\n\x02id\x18\x01 \x01(\t\"N\n\x14WaitOperationRequest\x12\n\n\x02id\x18\x01 \x01(\t\x12*\n\x07timeout\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\"}\n\x15ListOperationsRequest\x12=\n\x06\x66ilter\x18\x01 \x01(\x0b\x32-.tinkoff.cloud.longrunning.v1.OperationFilter\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"n\n\x16ListOperationsResponse\x12;\n\noperations\x18\x01 \x03(\x0b\x32\'.tinkoff.cloud.longrunning.v1.Operation\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"W\n\x16\x44\x65leteOperationRequest\x12=\n\x06\x66ilter\x18\x01 \x01(\x0b\x32-.tinkoff.cloud.longrunning.v1.OperationFilter\"W\n\x16\x43\x61ncelOperationRequest\x12=\n\x06\x66ilter\x18\x01 \x01(\x0b\x32-.tinkoff.cloud.longrunning.v1.OperationFilter\"s\n\x16WatchOperationsRequest\x12=\n\x06\x66ilter\x18\x01 \x01(\x0b\x32-.tinkoff.cloud.longrunning.v1.OperationFilter\x12\x1a\n\x12listen_for_updates\x18\x02 \x01(\x08\"U\n\x16OperationsInitialState\x12;\n\noperations\x18\x01 \x03(\x0b\x32\'.tinkoff.cloud.longrunning.v1.Operation\"O\n\x10OperationsUpdate\x12;\n\noperations\x18\x01 \x03(\x0b\x32\'.tinkoff.cloud.longrunning.v1.Operation\"\xe9\x01\n\x17WatchOperationsResponse\x12M\n\rinitial_state\x18\x01 \x01(\x0b\x32\x34.tinkoff.cloud.longrunning.v1.OperationsInitialStateH\x00\x12/\n\rinit_finished\x18\x02 \x01(\x0b\x32\x16.google.protobuf.EmptyH\x00\x12@\n\x06update\x18\x03 \x01(\x0b\x32..tinkoff.cloud.longrunning.v1.OperationsUpdateH\x00\x42\x0c\n\noperations*D\n\x0eOperationState\x12\x0c\n\x08\x45NQUEUED\x10\x00\x12\x0e\n\nPROCESSING\x10\x01\x12\x08\n\x04\x44ONE\x10\x02\x12\n\n\x06\x46\x41ILED\x10\x03\x32\xbf\x06\n\nOperations\x12\x87\x01\n\x0cGetOperation\x12\x31.tinkoff.cloud.longrunning.v1.GetOperationRequest\x1a\'.tinkoff.cloud.longrunning.v1.Operation\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/v1/operations/{id}\x12l\n\rWaitOperation\x12\x32.tinkoff.cloud.longrunning.v1.WaitOperationRequest\x1a\'.tinkoff.cloud.longrunning.v1.Operation\x12\x93\x01\n\x0eListOperations\x12\x33.tinkoff.cloud.longrunning.v1.ListOperationsRequest\x1a\x34.tinkoff.cloud.longrunning.v1.ListOperationsResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/v1/operations\x12\x80\x01\n\x0fWatchOperations\x12\x34.tinkoff.cloud.longrunning.v1.WatchOperationsRequest\x1a\x35.tinkoff.cloud.longrunning.v1.WatchOperationsResponse0\x01\x12\x89\x01\n\x0f\x44\x65leteOperation\x12\x34.tinkoff.cloud.longrunning.v1.DeleteOperationRequest\x1a\x16.google.protobuf.Empty\"(\x82\xd3\xe4\x93\x02\"* /v1/operations/{filter.exact_id}\x12\x93\x01\n\x0f\x43\x61ncelOperation\x12\x34.tinkoff.cloud.longrunning.v1.CancelOperationRequest\x1a\x16.google.protobuf.Empty\"2\x82\xd3\xe4\x93\x02,\"\'/v1/operations/{filter.exact_id}:cancel:\x01*BJZHstash.tcsbank.ru/stt/tinkoff_cloud_apis/pkg/tinkoff/cloud/longrunning/v1b\x06proto3' 29 | , 30 | dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_any__pb2.DESCRIPTOR,google_dot_protobuf_dot_duration__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_rpc_dot_status__pb2.DESCRIPTOR,]) 31 | 32 | _OPERATIONSTATE = _descriptor.EnumDescriptor( 33 | name='OperationState', 34 | full_name='tinkoff.cloud.longrunning.v1.OperationState', 35 | filename=None, 36 | file=DESCRIPTOR, 37 | create_key=_descriptor._internal_create_key, 38 | values=[ 39 | _descriptor.EnumValueDescriptor( 40 | name='ENQUEUED', index=0, number=0, 41 | serialized_options=None, 42 | type=None, 43 | create_key=_descriptor._internal_create_key), 44 | _descriptor.EnumValueDescriptor( 45 | name='PROCESSING', index=1, number=1, 46 | serialized_options=None, 47 | type=None, 48 | create_key=_descriptor._internal_create_key), 49 | _descriptor.EnumValueDescriptor( 50 | name='DONE', index=2, number=2, 51 | serialized_options=None, 52 | type=None, 53 | create_key=_descriptor._internal_create_key), 54 | _descriptor.EnumValueDescriptor( 55 | name='FAILED', index=3, number=3, 56 | serialized_options=None, 57 | type=None, 58 | create_key=_descriptor._internal_create_key), 59 | ], 60 | containing_type=None, 61 | serialized_options=None, 62 | serialized_start=1854, 63 | serialized_end=1922, 64 | ) 65 | _sym_db.RegisterEnumDescriptor(_OPERATIONSTATE) 66 | 67 | OperationState = enum_type_wrapper.EnumTypeWrapper(_OPERATIONSTATE) 68 | ENQUEUED = 0 69 | PROCESSING = 1 70 | DONE = 2 71 | FAILED = 3 72 | 73 | 74 | 75 | _OPERATION = _descriptor.Descriptor( 76 | name='Operation', 77 | full_name='tinkoff.cloud.longrunning.v1.Operation', 78 | filename=None, 79 | file=DESCRIPTOR, 80 | containing_type=None, 81 | create_key=_descriptor._internal_create_key, 82 | fields=[ 83 | _descriptor.FieldDescriptor( 84 | name='id', full_name='tinkoff.cloud.longrunning.v1.Operation.id', index=0, 85 | number=1, type=9, cpp_type=9, label=1, 86 | has_default_value=False, default_value=b"".decode('utf-8'), 87 | message_type=None, enum_type=None, containing_type=None, 88 | is_extension=False, extension_scope=None, 89 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 90 | _descriptor.FieldDescriptor( 91 | name='group', full_name='tinkoff.cloud.longrunning.v1.Operation.group', index=1, 92 | number=2, type=9, cpp_type=9, label=1, 93 | has_default_value=False, default_value=b"".decode('utf-8'), 94 | message_type=None, enum_type=None, containing_type=None, 95 | is_extension=False, extension_scope=None, 96 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 97 | _descriptor.FieldDescriptor( 98 | name='metadata', full_name='tinkoff.cloud.longrunning.v1.Operation.metadata', index=2, 99 | number=3, type=11, cpp_type=10, label=1, 100 | has_default_value=False, default_value=None, 101 | message_type=None, enum_type=None, containing_type=None, 102 | is_extension=False, extension_scope=None, 103 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 104 | _descriptor.FieldDescriptor( 105 | name='state', full_name='tinkoff.cloud.longrunning.v1.Operation.state', index=3, 106 | number=4, type=14, cpp_type=8, label=1, 107 | has_default_value=False, default_value=0, 108 | message_type=None, enum_type=None, containing_type=None, 109 | is_extension=False, extension_scope=None, 110 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 111 | _descriptor.FieldDescriptor( 112 | name='error', full_name='tinkoff.cloud.longrunning.v1.Operation.error', index=4, 113 | number=5, type=11, cpp_type=10, label=1, 114 | has_default_value=False, default_value=None, 115 | message_type=None, enum_type=None, containing_type=None, 116 | is_extension=False, extension_scope=None, 117 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 118 | _descriptor.FieldDescriptor( 119 | name='response', full_name='tinkoff.cloud.longrunning.v1.Operation.response', index=5, 120 | number=6, type=11, cpp_type=10, label=1, 121 | has_default_value=False, default_value=None, 122 | message_type=None, enum_type=None, containing_type=None, 123 | is_extension=False, extension_scope=None, 124 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 125 | _descriptor.FieldDescriptor( 126 | name='x_client_request_id', full_name='tinkoff.cloud.longrunning.v1.Operation.x_client_request_id', index=6, 127 | number=7, type=9, cpp_type=9, label=1, 128 | has_default_value=False, default_value=b"".decode('utf-8'), 129 | message_type=None, enum_type=None, containing_type=None, 130 | is_extension=False, extension_scope=None, 131 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 132 | ], 133 | extensions=[ 134 | ], 135 | nested_types=[], 136 | enum_types=[ 137 | ], 138 | serialized_options=None, 139 | is_extendable=False, 140 | syntax='proto3', 141 | extension_ranges=[], 142 | oneofs=[ 143 | _descriptor.OneofDescriptor( 144 | name='result', full_name='tinkoff.cloud.longrunning.v1.Operation.result', 145 | index=0, containing_type=None, 146 | create_key=_descriptor._internal_create_key, 147 | fields=[]), 148 | ], 149 | serialized_start=224, 150 | serialized_end=481, 151 | ) 152 | 153 | 154 | _OPERATIONFILTER = _descriptor.Descriptor( 155 | name='OperationFilter', 156 | full_name='tinkoff.cloud.longrunning.v1.OperationFilter', 157 | filename=None, 158 | file=DESCRIPTOR, 159 | containing_type=None, 160 | create_key=_descriptor._internal_create_key, 161 | fields=[ 162 | _descriptor.FieldDescriptor( 163 | name='exact_service_id', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.exact_service_id', index=0, 164 | number=1, type=9, cpp_type=9, label=1, 165 | has_default_value=False, default_value=b"".decode('utf-8'), 166 | message_type=None, enum_type=None, containing_type=None, 167 | is_extension=False, extension_scope=None, 168 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 169 | _descriptor.FieldDescriptor( 170 | name='any_service_id', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.any_service_id', index=1, 171 | number=2, type=11, cpp_type=10, label=1, 172 | has_default_value=False, default_value=None, 173 | message_type=None, enum_type=None, containing_type=None, 174 | is_extension=False, extension_scope=None, 175 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 176 | _descriptor.FieldDescriptor( 177 | name='exact_id', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.exact_id', index=2, 178 | number=3, type=9, cpp_type=9, label=1, 179 | has_default_value=False, default_value=b"".decode('utf-8'), 180 | message_type=None, enum_type=None, containing_type=None, 181 | is_extension=False, extension_scope=None, 182 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 183 | _descriptor.FieldDescriptor( 184 | name='any_id', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.any_id', index=3, 185 | number=4, type=11, cpp_type=10, label=1, 186 | has_default_value=False, default_value=None, 187 | message_type=None, enum_type=None, containing_type=None, 188 | is_extension=False, extension_scope=None, 189 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 190 | _descriptor.FieldDescriptor( 191 | name='exact_group', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.exact_group', index=4, 192 | number=5, type=9, cpp_type=9, label=1, 193 | has_default_value=False, default_value=b"".decode('utf-8'), 194 | message_type=None, enum_type=None, containing_type=None, 195 | is_extension=False, extension_scope=None, 196 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 197 | _descriptor.FieldDescriptor( 198 | name='any_group', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.any_group', index=5, 199 | number=6, type=11, cpp_type=10, label=1, 200 | has_default_value=False, default_value=None, 201 | message_type=None, enum_type=None, containing_type=None, 202 | is_extension=False, extension_scope=None, 203 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 204 | _descriptor.FieldDescriptor( 205 | name='state', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.state', index=6, 206 | number=7, type=14, cpp_type=8, label=3, 207 | has_default_value=False, default_value=[], 208 | message_type=None, enum_type=None, containing_type=None, 209 | is_extension=False, extension_scope=None, 210 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 211 | ], 212 | extensions=[ 213 | ], 214 | nested_types=[], 215 | enum_types=[ 216 | ], 217 | serialized_options=None, 218 | is_extendable=False, 219 | syntax='proto3', 220 | extension_ranges=[], 221 | oneofs=[ 222 | _descriptor.OneofDescriptor( 223 | name='service_id', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.service_id', 224 | index=0, containing_type=None, 225 | create_key=_descriptor._internal_create_key, 226 | fields=[]), 227 | _descriptor.OneofDescriptor( 228 | name='id', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.id', 229 | index=1, containing_type=None, 230 | create_key=_descriptor._internal_create_key, 231 | fields=[]), 232 | _descriptor.OneofDescriptor( 233 | name='group', full_name='tinkoff.cloud.longrunning.v1.OperationFilter.group', 234 | index=2, containing_type=None, 235 | create_key=_descriptor._internal_create_key, 236 | fields=[]), 237 | ], 238 | serialized_start=484, 239 | serialized_end=799, 240 | ) 241 | 242 | 243 | _GETOPERATIONREQUEST = _descriptor.Descriptor( 244 | name='GetOperationRequest', 245 | full_name='tinkoff.cloud.longrunning.v1.GetOperationRequest', 246 | filename=None, 247 | file=DESCRIPTOR, 248 | containing_type=None, 249 | create_key=_descriptor._internal_create_key, 250 | fields=[ 251 | _descriptor.FieldDescriptor( 252 | name='id', full_name='tinkoff.cloud.longrunning.v1.GetOperationRequest.id', index=0, 253 | number=1, type=9, cpp_type=9, label=1, 254 | has_default_value=False, default_value=b"".decode('utf-8'), 255 | message_type=None, enum_type=None, containing_type=None, 256 | is_extension=False, extension_scope=None, 257 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 258 | ], 259 | extensions=[ 260 | ], 261 | nested_types=[], 262 | enum_types=[ 263 | ], 264 | serialized_options=None, 265 | is_extendable=False, 266 | syntax='proto3', 267 | extension_ranges=[], 268 | oneofs=[ 269 | ], 270 | serialized_start=801, 271 | serialized_end=834, 272 | ) 273 | 274 | 275 | _WAITOPERATIONREQUEST = _descriptor.Descriptor( 276 | name='WaitOperationRequest', 277 | full_name='tinkoff.cloud.longrunning.v1.WaitOperationRequest', 278 | filename=None, 279 | file=DESCRIPTOR, 280 | containing_type=None, 281 | create_key=_descriptor._internal_create_key, 282 | fields=[ 283 | _descriptor.FieldDescriptor( 284 | name='id', full_name='tinkoff.cloud.longrunning.v1.WaitOperationRequest.id', index=0, 285 | number=1, type=9, cpp_type=9, label=1, 286 | has_default_value=False, default_value=b"".decode('utf-8'), 287 | message_type=None, enum_type=None, containing_type=None, 288 | is_extension=False, extension_scope=None, 289 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 290 | _descriptor.FieldDescriptor( 291 | name='timeout', full_name='tinkoff.cloud.longrunning.v1.WaitOperationRequest.timeout', index=1, 292 | number=2, type=11, cpp_type=10, label=1, 293 | has_default_value=False, default_value=None, 294 | message_type=None, enum_type=None, containing_type=None, 295 | is_extension=False, extension_scope=None, 296 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 297 | ], 298 | extensions=[ 299 | ], 300 | nested_types=[], 301 | enum_types=[ 302 | ], 303 | serialized_options=None, 304 | is_extendable=False, 305 | syntax='proto3', 306 | extension_ranges=[], 307 | oneofs=[ 308 | ], 309 | serialized_start=836, 310 | serialized_end=914, 311 | ) 312 | 313 | 314 | _LISTOPERATIONSREQUEST = _descriptor.Descriptor( 315 | name='ListOperationsRequest', 316 | full_name='tinkoff.cloud.longrunning.v1.ListOperationsRequest', 317 | filename=None, 318 | file=DESCRIPTOR, 319 | containing_type=None, 320 | create_key=_descriptor._internal_create_key, 321 | fields=[ 322 | _descriptor.FieldDescriptor( 323 | name='filter', full_name='tinkoff.cloud.longrunning.v1.ListOperationsRequest.filter', index=0, 324 | number=1, type=11, cpp_type=10, label=1, 325 | has_default_value=False, default_value=None, 326 | message_type=None, enum_type=None, containing_type=None, 327 | is_extension=False, extension_scope=None, 328 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 329 | _descriptor.FieldDescriptor( 330 | name='page_size', full_name='tinkoff.cloud.longrunning.v1.ListOperationsRequest.page_size', index=1, 331 | number=2, type=5, cpp_type=1, label=1, 332 | has_default_value=False, default_value=0, 333 | message_type=None, enum_type=None, containing_type=None, 334 | is_extension=False, extension_scope=None, 335 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 336 | _descriptor.FieldDescriptor( 337 | name='page_token', full_name='tinkoff.cloud.longrunning.v1.ListOperationsRequest.page_token', index=2, 338 | number=3, type=9, cpp_type=9, label=1, 339 | has_default_value=False, default_value=b"".decode('utf-8'), 340 | message_type=None, enum_type=None, containing_type=None, 341 | is_extension=False, extension_scope=None, 342 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 343 | ], 344 | extensions=[ 345 | ], 346 | nested_types=[], 347 | enum_types=[ 348 | ], 349 | serialized_options=None, 350 | is_extendable=False, 351 | syntax='proto3', 352 | extension_ranges=[], 353 | oneofs=[ 354 | ], 355 | serialized_start=916, 356 | serialized_end=1041, 357 | ) 358 | 359 | 360 | _LISTOPERATIONSRESPONSE = _descriptor.Descriptor( 361 | name='ListOperationsResponse', 362 | full_name='tinkoff.cloud.longrunning.v1.ListOperationsResponse', 363 | filename=None, 364 | file=DESCRIPTOR, 365 | containing_type=None, 366 | create_key=_descriptor._internal_create_key, 367 | fields=[ 368 | _descriptor.FieldDescriptor( 369 | name='operations', full_name='tinkoff.cloud.longrunning.v1.ListOperationsResponse.operations', index=0, 370 | number=1, type=11, cpp_type=10, label=3, 371 | has_default_value=False, default_value=[], 372 | message_type=None, enum_type=None, containing_type=None, 373 | is_extension=False, extension_scope=None, 374 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 375 | _descriptor.FieldDescriptor( 376 | name='next_page_token', full_name='tinkoff.cloud.longrunning.v1.ListOperationsResponse.next_page_token', index=1, 377 | number=2, type=9, cpp_type=9, label=1, 378 | has_default_value=False, default_value=b"".decode('utf-8'), 379 | message_type=None, enum_type=None, containing_type=None, 380 | is_extension=False, extension_scope=None, 381 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 382 | ], 383 | extensions=[ 384 | ], 385 | nested_types=[], 386 | enum_types=[ 387 | ], 388 | serialized_options=None, 389 | is_extendable=False, 390 | syntax='proto3', 391 | extension_ranges=[], 392 | oneofs=[ 393 | ], 394 | serialized_start=1043, 395 | serialized_end=1153, 396 | ) 397 | 398 | 399 | _DELETEOPERATIONREQUEST = _descriptor.Descriptor( 400 | name='DeleteOperationRequest', 401 | full_name='tinkoff.cloud.longrunning.v1.DeleteOperationRequest', 402 | filename=None, 403 | file=DESCRIPTOR, 404 | containing_type=None, 405 | create_key=_descriptor._internal_create_key, 406 | fields=[ 407 | _descriptor.FieldDescriptor( 408 | name='filter', full_name='tinkoff.cloud.longrunning.v1.DeleteOperationRequest.filter', index=0, 409 | number=1, type=11, cpp_type=10, label=1, 410 | has_default_value=False, default_value=None, 411 | message_type=None, enum_type=None, containing_type=None, 412 | is_extension=False, extension_scope=None, 413 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 414 | ], 415 | extensions=[ 416 | ], 417 | nested_types=[], 418 | enum_types=[ 419 | ], 420 | serialized_options=None, 421 | is_extendable=False, 422 | syntax='proto3', 423 | extension_ranges=[], 424 | oneofs=[ 425 | ], 426 | serialized_start=1155, 427 | serialized_end=1242, 428 | ) 429 | 430 | 431 | _CANCELOPERATIONREQUEST = _descriptor.Descriptor( 432 | name='CancelOperationRequest', 433 | full_name='tinkoff.cloud.longrunning.v1.CancelOperationRequest', 434 | filename=None, 435 | file=DESCRIPTOR, 436 | containing_type=None, 437 | create_key=_descriptor._internal_create_key, 438 | fields=[ 439 | _descriptor.FieldDescriptor( 440 | name='filter', full_name='tinkoff.cloud.longrunning.v1.CancelOperationRequest.filter', index=0, 441 | number=1, type=11, cpp_type=10, label=1, 442 | has_default_value=False, default_value=None, 443 | message_type=None, enum_type=None, containing_type=None, 444 | is_extension=False, extension_scope=None, 445 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 446 | ], 447 | extensions=[ 448 | ], 449 | nested_types=[], 450 | enum_types=[ 451 | ], 452 | serialized_options=None, 453 | is_extendable=False, 454 | syntax='proto3', 455 | extension_ranges=[], 456 | oneofs=[ 457 | ], 458 | serialized_start=1244, 459 | serialized_end=1331, 460 | ) 461 | 462 | 463 | _WATCHOPERATIONSREQUEST = _descriptor.Descriptor( 464 | name='WatchOperationsRequest', 465 | full_name='tinkoff.cloud.longrunning.v1.WatchOperationsRequest', 466 | filename=None, 467 | file=DESCRIPTOR, 468 | containing_type=None, 469 | create_key=_descriptor._internal_create_key, 470 | fields=[ 471 | _descriptor.FieldDescriptor( 472 | name='filter', full_name='tinkoff.cloud.longrunning.v1.WatchOperationsRequest.filter', index=0, 473 | number=1, type=11, cpp_type=10, label=1, 474 | has_default_value=False, default_value=None, 475 | message_type=None, enum_type=None, containing_type=None, 476 | is_extension=False, extension_scope=None, 477 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 478 | _descriptor.FieldDescriptor( 479 | name='listen_for_updates', full_name='tinkoff.cloud.longrunning.v1.WatchOperationsRequest.listen_for_updates', index=1, 480 | number=2, type=8, cpp_type=7, label=1, 481 | has_default_value=False, default_value=False, 482 | message_type=None, enum_type=None, containing_type=None, 483 | is_extension=False, extension_scope=None, 484 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 485 | ], 486 | extensions=[ 487 | ], 488 | nested_types=[], 489 | enum_types=[ 490 | ], 491 | serialized_options=None, 492 | is_extendable=False, 493 | syntax='proto3', 494 | extension_ranges=[], 495 | oneofs=[ 496 | ], 497 | serialized_start=1333, 498 | serialized_end=1448, 499 | ) 500 | 501 | 502 | _OPERATIONSINITIALSTATE = _descriptor.Descriptor( 503 | name='OperationsInitialState', 504 | full_name='tinkoff.cloud.longrunning.v1.OperationsInitialState', 505 | filename=None, 506 | file=DESCRIPTOR, 507 | containing_type=None, 508 | create_key=_descriptor._internal_create_key, 509 | fields=[ 510 | _descriptor.FieldDescriptor( 511 | name='operations', full_name='tinkoff.cloud.longrunning.v1.OperationsInitialState.operations', index=0, 512 | number=1, type=11, cpp_type=10, label=3, 513 | has_default_value=False, default_value=[], 514 | message_type=None, enum_type=None, containing_type=None, 515 | is_extension=False, extension_scope=None, 516 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 517 | ], 518 | extensions=[ 519 | ], 520 | nested_types=[], 521 | enum_types=[ 522 | ], 523 | serialized_options=None, 524 | is_extendable=False, 525 | syntax='proto3', 526 | extension_ranges=[], 527 | oneofs=[ 528 | ], 529 | serialized_start=1450, 530 | serialized_end=1535, 531 | ) 532 | 533 | 534 | _OPERATIONSUPDATE = _descriptor.Descriptor( 535 | name='OperationsUpdate', 536 | full_name='tinkoff.cloud.longrunning.v1.OperationsUpdate', 537 | filename=None, 538 | file=DESCRIPTOR, 539 | containing_type=None, 540 | create_key=_descriptor._internal_create_key, 541 | fields=[ 542 | _descriptor.FieldDescriptor( 543 | name='operations', full_name='tinkoff.cloud.longrunning.v1.OperationsUpdate.operations', index=0, 544 | number=1, type=11, cpp_type=10, label=3, 545 | has_default_value=False, default_value=[], 546 | message_type=None, enum_type=None, containing_type=None, 547 | is_extension=False, extension_scope=None, 548 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 549 | ], 550 | extensions=[ 551 | ], 552 | nested_types=[], 553 | enum_types=[ 554 | ], 555 | serialized_options=None, 556 | is_extendable=False, 557 | syntax='proto3', 558 | extension_ranges=[], 559 | oneofs=[ 560 | ], 561 | serialized_start=1537, 562 | serialized_end=1616, 563 | ) 564 | 565 | 566 | _WATCHOPERATIONSRESPONSE = _descriptor.Descriptor( 567 | name='WatchOperationsResponse', 568 | full_name='tinkoff.cloud.longrunning.v1.WatchOperationsResponse', 569 | filename=None, 570 | file=DESCRIPTOR, 571 | containing_type=None, 572 | create_key=_descriptor._internal_create_key, 573 | fields=[ 574 | _descriptor.FieldDescriptor( 575 | name='initial_state', full_name='tinkoff.cloud.longrunning.v1.WatchOperationsResponse.initial_state', index=0, 576 | number=1, type=11, cpp_type=10, label=1, 577 | has_default_value=False, default_value=None, 578 | message_type=None, enum_type=None, containing_type=None, 579 | is_extension=False, extension_scope=None, 580 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 581 | _descriptor.FieldDescriptor( 582 | name='init_finished', full_name='tinkoff.cloud.longrunning.v1.WatchOperationsResponse.init_finished', index=1, 583 | number=2, type=11, cpp_type=10, label=1, 584 | has_default_value=False, default_value=None, 585 | message_type=None, enum_type=None, containing_type=None, 586 | is_extension=False, extension_scope=None, 587 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 588 | _descriptor.FieldDescriptor( 589 | name='update', full_name='tinkoff.cloud.longrunning.v1.WatchOperationsResponse.update', index=2, 590 | number=3, type=11, cpp_type=10, label=1, 591 | has_default_value=False, default_value=None, 592 | message_type=None, enum_type=None, containing_type=None, 593 | is_extension=False, extension_scope=None, 594 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 595 | ], 596 | extensions=[ 597 | ], 598 | nested_types=[], 599 | enum_types=[ 600 | ], 601 | serialized_options=None, 602 | is_extendable=False, 603 | syntax='proto3', 604 | extension_ranges=[], 605 | oneofs=[ 606 | _descriptor.OneofDescriptor( 607 | name='operations', full_name='tinkoff.cloud.longrunning.v1.WatchOperationsResponse.operations', 608 | index=0, containing_type=None, 609 | create_key=_descriptor._internal_create_key, 610 | fields=[]), 611 | ], 612 | serialized_start=1619, 613 | serialized_end=1852, 614 | ) 615 | 616 | _OPERATION.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_any__pb2._ANY 617 | _OPERATION.fields_by_name['state'].enum_type = _OPERATIONSTATE 618 | _OPERATION.fields_by_name['error'].message_type = google_dot_rpc_dot_status__pb2._STATUS 619 | _OPERATION.fields_by_name['response'].message_type = google_dot_protobuf_dot_any__pb2._ANY 620 | _OPERATION.oneofs_by_name['result'].fields.append( 621 | _OPERATION.fields_by_name['error']) 622 | _OPERATION.fields_by_name['error'].containing_oneof = _OPERATION.oneofs_by_name['result'] 623 | _OPERATION.oneofs_by_name['result'].fields.append( 624 | _OPERATION.fields_by_name['response']) 625 | _OPERATION.fields_by_name['response'].containing_oneof = _OPERATION.oneofs_by_name['result'] 626 | _OPERATIONFILTER.fields_by_name['any_service_id'].message_type = google_dot_protobuf_dot_empty__pb2._EMPTY 627 | _OPERATIONFILTER.fields_by_name['any_id'].message_type = google_dot_protobuf_dot_empty__pb2._EMPTY 628 | _OPERATIONFILTER.fields_by_name['any_group'].message_type = google_dot_protobuf_dot_empty__pb2._EMPTY 629 | _OPERATIONFILTER.fields_by_name['state'].enum_type = _OPERATIONSTATE 630 | _OPERATIONFILTER.oneofs_by_name['service_id'].fields.append( 631 | _OPERATIONFILTER.fields_by_name['exact_service_id']) 632 | _OPERATIONFILTER.fields_by_name['exact_service_id'].containing_oneof = _OPERATIONFILTER.oneofs_by_name['service_id'] 633 | _OPERATIONFILTER.oneofs_by_name['service_id'].fields.append( 634 | _OPERATIONFILTER.fields_by_name['any_service_id']) 635 | _OPERATIONFILTER.fields_by_name['any_service_id'].containing_oneof = _OPERATIONFILTER.oneofs_by_name['service_id'] 636 | _OPERATIONFILTER.oneofs_by_name['id'].fields.append( 637 | _OPERATIONFILTER.fields_by_name['exact_id']) 638 | _OPERATIONFILTER.fields_by_name['exact_id'].containing_oneof = _OPERATIONFILTER.oneofs_by_name['id'] 639 | _OPERATIONFILTER.oneofs_by_name['id'].fields.append( 640 | _OPERATIONFILTER.fields_by_name['any_id']) 641 | _OPERATIONFILTER.fields_by_name['any_id'].containing_oneof = _OPERATIONFILTER.oneofs_by_name['id'] 642 | _OPERATIONFILTER.oneofs_by_name['group'].fields.append( 643 | _OPERATIONFILTER.fields_by_name['exact_group']) 644 | _OPERATIONFILTER.fields_by_name['exact_group'].containing_oneof = _OPERATIONFILTER.oneofs_by_name['group'] 645 | _OPERATIONFILTER.oneofs_by_name['group'].fields.append( 646 | _OPERATIONFILTER.fields_by_name['any_group']) 647 | _OPERATIONFILTER.fields_by_name['any_group'].containing_oneof = _OPERATIONFILTER.oneofs_by_name['group'] 648 | _WAITOPERATIONREQUEST.fields_by_name['timeout'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION 649 | _LISTOPERATIONSREQUEST.fields_by_name['filter'].message_type = _OPERATIONFILTER 650 | _LISTOPERATIONSRESPONSE.fields_by_name['operations'].message_type = _OPERATION 651 | _DELETEOPERATIONREQUEST.fields_by_name['filter'].message_type = _OPERATIONFILTER 652 | _CANCELOPERATIONREQUEST.fields_by_name['filter'].message_type = _OPERATIONFILTER 653 | _WATCHOPERATIONSREQUEST.fields_by_name['filter'].message_type = _OPERATIONFILTER 654 | _OPERATIONSINITIALSTATE.fields_by_name['operations'].message_type = _OPERATION 655 | _OPERATIONSUPDATE.fields_by_name['operations'].message_type = _OPERATION 656 | _WATCHOPERATIONSRESPONSE.fields_by_name['initial_state'].message_type = _OPERATIONSINITIALSTATE 657 | _WATCHOPERATIONSRESPONSE.fields_by_name['init_finished'].message_type = google_dot_protobuf_dot_empty__pb2._EMPTY 658 | _WATCHOPERATIONSRESPONSE.fields_by_name['update'].message_type = _OPERATIONSUPDATE 659 | _WATCHOPERATIONSRESPONSE.oneofs_by_name['operations'].fields.append( 660 | _WATCHOPERATIONSRESPONSE.fields_by_name['initial_state']) 661 | _WATCHOPERATIONSRESPONSE.fields_by_name['initial_state'].containing_oneof = _WATCHOPERATIONSRESPONSE.oneofs_by_name['operations'] 662 | _WATCHOPERATIONSRESPONSE.oneofs_by_name['operations'].fields.append( 663 | _WATCHOPERATIONSRESPONSE.fields_by_name['init_finished']) 664 | _WATCHOPERATIONSRESPONSE.fields_by_name['init_finished'].containing_oneof = _WATCHOPERATIONSRESPONSE.oneofs_by_name['operations'] 665 | _WATCHOPERATIONSRESPONSE.oneofs_by_name['operations'].fields.append( 666 | _WATCHOPERATIONSRESPONSE.fields_by_name['update']) 667 | _WATCHOPERATIONSRESPONSE.fields_by_name['update'].containing_oneof = _WATCHOPERATIONSRESPONSE.oneofs_by_name['operations'] 668 | DESCRIPTOR.message_types_by_name['Operation'] = _OPERATION 669 | DESCRIPTOR.message_types_by_name['OperationFilter'] = _OPERATIONFILTER 670 | DESCRIPTOR.message_types_by_name['GetOperationRequest'] = _GETOPERATIONREQUEST 671 | DESCRIPTOR.message_types_by_name['WaitOperationRequest'] = _WAITOPERATIONREQUEST 672 | DESCRIPTOR.message_types_by_name['ListOperationsRequest'] = _LISTOPERATIONSREQUEST 673 | DESCRIPTOR.message_types_by_name['ListOperationsResponse'] = _LISTOPERATIONSRESPONSE 674 | DESCRIPTOR.message_types_by_name['DeleteOperationRequest'] = _DELETEOPERATIONREQUEST 675 | DESCRIPTOR.message_types_by_name['CancelOperationRequest'] = _CANCELOPERATIONREQUEST 676 | DESCRIPTOR.message_types_by_name['WatchOperationsRequest'] = _WATCHOPERATIONSREQUEST 677 | DESCRIPTOR.message_types_by_name['OperationsInitialState'] = _OPERATIONSINITIALSTATE 678 | DESCRIPTOR.message_types_by_name['OperationsUpdate'] = _OPERATIONSUPDATE 679 | DESCRIPTOR.message_types_by_name['WatchOperationsResponse'] = _WATCHOPERATIONSRESPONSE 680 | DESCRIPTOR.enum_types_by_name['OperationState'] = _OPERATIONSTATE 681 | _sym_db.RegisterFileDescriptor(DESCRIPTOR) 682 | 683 | Operation = _reflection.GeneratedProtocolMessageType('Operation', (_message.Message,), { 684 | 'DESCRIPTOR' : _OPERATION, 685 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 686 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.Operation) 687 | }) 688 | _sym_db.RegisterMessage(Operation) 689 | 690 | OperationFilter = _reflection.GeneratedProtocolMessageType('OperationFilter', (_message.Message,), { 691 | 'DESCRIPTOR' : _OPERATIONFILTER, 692 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 693 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.OperationFilter) 694 | }) 695 | _sym_db.RegisterMessage(OperationFilter) 696 | 697 | GetOperationRequest = _reflection.GeneratedProtocolMessageType('GetOperationRequest', (_message.Message,), { 698 | 'DESCRIPTOR' : _GETOPERATIONREQUEST, 699 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 700 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.GetOperationRequest) 701 | }) 702 | _sym_db.RegisterMessage(GetOperationRequest) 703 | 704 | WaitOperationRequest = _reflection.GeneratedProtocolMessageType('WaitOperationRequest', (_message.Message,), { 705 | 'DESCRIPTOR' : _WAITOPERATIONREQUEST, 706 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 707 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.WaitOperationRequest) 708 | }) 709 | _sym_db.RegisterMessage(WaitOperationRequest) 710 | 711 | ListOperationsRequest = _reflection.GeneratedProtocolMessageType('ListOperationsRequest', (_message.Message,), { 712 | 'DESCRIPTOR' : _LISTOPERATIONSREQUEST, 713 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 714 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.ListOperationsRequest) 715 | }) 716 | _sym_db.RegisterMessage(ListOperationsRequest) 717 | 718 | ListOperationsResponse = _reflection.GeneratedProtocolMessageType('ListOperationsResponse', (_message.Message,), { 719 | 'DESCRIPTOR' : _LISTOPERATIONSRESPONSE, 720 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 721 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.ListOperationsResponse) 722 | }) 723 | _sym_db.RegisterMessage(ListOperationsResponse) 724 | 725 | DeleteOperationRequest = _reflection.GeneratedProtocolMessageType('DeleteOperationRequest', (_message.Message,), { 726 | 'DESCRIPTOR' : _DELETEOPERATIONREQUEST, 727 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 728 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.DeleteOperationRequest) 729 | }) 730 | _sym_db.RegisterMessage(DeleteOperationRequest) 731 | 732 | CancelOperationRequest = _reflection.GeneratedProtocolMessageType('CancelOperationRequest', (_message.Message,), { 733 | 'DESCRIPTOR' : _CANCELOPERATIONREQUEST, 734 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 735 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.CancelOperationRequest) 736 | }) 737 | _sym_db.RegisterMessage(CancelOperationRequest) 738 | 739 | WatchOperationsRequest = _reflection.GeneratedProtocolMessageType('WatchOperationsRequest', (_message.Message,), { 740 | 'DESCRIPTOR' : _WATCHOPERATIONSREQUEST, 741 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 742 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.WatchOperationsRequest) 743 | }) 744 | _sym_db.RegisterMessage(WatchOperationsRequest) 745 | 746 | OperationsInitialState = _reflection.GeneratedProtocolMessageType('OperationsInitialState', (_message.Message,), { 747 | 'DESCRIPTOR' : _OPERATIONSINITIALSTATE, 748 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 749 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.OperationsInitialState) 750 | }) 751 | _sym_db.RegisterMessage(OperationsInitialState) 752 | 753 | OperationsUpdate = _reflection.GeneratedProtocolMessageType('OperationsUpdate', (_message.Message,), { 754 | 'DESCRIPTOR' : _OPERATIONSUPDATE, 755 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 756 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.OperationsUpdate) 757 | }) 758 | _sym_db.RegisterMessage(OperationsUpdate) 759 | 760 | WatchOperationsResponse = _reflection.GeneratedProtocolMessageType('WatchOperationsResponse', (_message.Message,), { 761 | 'DESCRIPTOR' : _WATCHOPERATIONSRESPONSE, 762 | '__module__' : 'tinkoff.cloud.longrunning.v1.longrunning_pb2' 763 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.longrunning.v1.WatchOperationsResponse) 764 | }) 765 | _sym_db.RegisterMessage(WatchOperationsResponse) 766 | 767 | 768 | DESCRIPTOR._options = None 769 | 770 | _OPERATIONS = _descriptor.ServiceDescriptor( 771 | name='Operations', 772 | full_name='tinkoff.cloud.longrunning.v1.Operations', 773 | file=DESCRIPTOR, 774 | index=0, 775 | serialized_options=None, 776 | create_key=_descriptor._internal_create_key, 777 | serialized_start=1925, 778 | serialized_end=2756, 779 | methods=[ 780 | _descriptor.MethodDescriptor( 781 | name='GetOperation', 782 | full_name='tinkoff.cloud.longrunning.v1.Operations.GetOperation', 783 | index=0, 784 | containing_service=None, 785 | input_type=_GETOPERATIONREQUEST, 786 | output_type=_OPERATION, 787 | serialized_options=b'\202\323\344\223\002\025\022\023/v1/operations/{id}', 788 | create_key=_descriptor._internal_create_key, 789 | ), 790 | _descriptor.MethodDescriptor( 791 | name='WaitOperation', 792 | full_name='tinkoff.cloud.longrunning.v1.Operations.WaitOperation', 793 | index=1, 794 | containing_service=None, 795 | input_type=_WAITOPERATIONREQUEST, 796 | output_type=_OPERATION, 797 | serialized_options=None, 798 | create_key=_descriptor._internal_create_key, 799 | ), 800 | _descriptor.MethodDescriptor( 801 | name='ListOperations', 802 | full_name='tinkoff.cloud.longrunning.v1.Operations.ListOperations', 803 | index=2, 804 | containing_service=None, 805 | input_type=_LISTOPERATIONSREQUEST, 806 | output_type=_LISTOPERATIONSRESPONSE, 807 | serialized_options=b'\202\323\344\223\002\020\022\016/v1/operations', 808 | create_key=_descriptor._internal_create_key, 809 | ), 810 | _descriptor.MethodDescriptor( 811 | name='WatchOperations', 812 | full_name='tinkoff.cloud.longrunning.v1.Operations.WatchOperations', 813 | index=3, 814 | containing_service=None, 815 | input_type=_WATCHOPERATIONSREQUEST, 816 | output_type=_WATCHOPERATIONSRESPONSE, 817 | serialized_options=None, 818 | create_key=_descriptor._internal_create_key, 819 | ), 820 | _descriptor.MethodDescriptor( 821 | name='DeleteOperation', 822 | full_name='tinkoff.cloud.longrunning.v1.Operations.DeleteOperation', 823 | index=4, 824 | containing_service=None, 825 | input_type=_DELETEOPERATIONREQUEST, 826 | output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, 827 | serialized_options=b'\202\323\344\223\002\"* /v1/operations/{filter.exact_id}', 828 | create_key=_descriptor._internal_create_key, 829 | ), 830 | _descriptor.MethodDescriptor( 831 | name='CancelOperation', 832 | full_name='tinkoff.cloud.longrunning.v1.Operations.CancelOperation', 833 | index=5, 834 | containing_service=None, 835 | input_type=_CANCELOPERATIONREQUEST, 836 | output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, 837 | serialized_options=b'\202\323\344\223\002,\"\'/v1/operations/{filter.exact_id}:cancel:\001*', 838 | create_key=_descriptor._internal_create_key, 839 | ), 840 | ]) 841 | _sym_db.RegisterServiceDescriptor(_OPERATIONS) 842 | 843 | DESCRIPTOR.services_by_name['Operations'] = _OPERATIONS 844 | 845 | # @@protoc_insertion_point(module_scope) 846 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/longrunning/v1/longrunning_pb2_grpc.py: -------------------------------------------------------------------------------- 1 | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! 2 | """Client and server classes corresponding to protobuf-defined services.""" 3 | import grpc 4 | 5 | from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 6 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.longrunning.v1 import longrunning_pb2 as tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2 7 | 8 | 9 | class OperationsStub(object): 10 | """Missing associated documentation comment in .proto file.""" 11 | 12 | def __init__(self, channel): 13 | """Constructor. 14 | 15 | Args: 16 | channel: A grpc.Channel. 17 | """ 18 | self.GetOperation = channel.unary_unary( 19 | '/tinkoff.cloud.longrunning.v1.Operations/GetOperation', 20 | request_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.GetOperationRequest.SerializeToString, 21 | response_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.FromString, 22 | ) 23 | self.WaitOperation = channel.unary_unary( 24 | '/tinkoff.cloud.longrunning.v1.Operations/WaitOperation', 25 | request_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WaitOperationRequest.SerializeToString, 26 | response_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.FromString, 27 | ) 28 | self.ListOperations = channel.unary_unary( 29 | '/tinkoff.cloud.longrunning.v1.Operations/ListOperations', 30 | request_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.ListOperationsRequest.SerializeToString, 31 | response_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.ListOperationsResponse.FromString, 32 | ) 33 | self.WatchOperations = channel.unary_stream( 34 | '/tinkoff.cloud.longrunning.v1.Operations/WatchOperations', 35 | request_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WatchOperationsRequest.SerializeToString, 36 | response_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WatchOperationsResponse.FromString, 37 | ) 38 | self.DeleteOperation = channel.unary_unary( 39 | '/tinkoff.cloud.longrunning.v1.Operations/DeleteOperation', 40 | request_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.DeleteOperationRequest.SerializeToString, 41 | response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, 42 | ) 43 | self.CancelOperation = channel.unary_unary( 44 | '/tinkoff.cloud.longrunning.v1.Operations/CancelOperation', 45 | request_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.CancelOperationRequest.SerializeToString, 46 | response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, 47 | ) 48 | 49 | 50 | class OperationsServicer(object): 51 | """Missing associated documentation comment in .proto file.""" 52 | 53 | def GetOperation(self, request, context): 54 | """Starts polling for operation statuses 55 | Returns operation status 56 | """ 57 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 58 | context.set_details('Method not implemented!') 59 | raise NotImplementedError('Method not implemented!') 60 | 61 | def WaitOperation(self, request, context): 62 | """Wait for operation update 63 | """ 64 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 65 | context.set_details('Method not implemented!') 66 | raise NotImplementedError('Method not implemented!') 67 | 68 | def ListOperations(self, request, context): 69 | """List operations 70 | """ 71 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 72 | context.set_details('Method not implemented!') 73 | raise NotImplementedError('Method not implemented!') 74 | 75 | def WatchOperations(self, request, context): 76 | """Watch operations 77 | """ 78 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 79 | context.set_details('Method not implemented!') 80 | raise NotImplementedError('Method not implemented!') 81 | 82 | def DeleteOperation(self, request, context): 83 | """Deletes spepcified operations 84 | """ 85 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 86 | context.set_details('Method not implemented!') 87 | raise NotImplementedError('Method not implemented!') 88 | 89 | def CancelOperation(self, request, context): 90 | """Cancels spepcified operations 91 | """ 92 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 93 | context.set_details('Method not implemented!') 94 | raise NotImplementedError('Method not implemented!') 95 | 96 | 97 | def add_OperationsServicer_to_server(servicer, server): 98 | rpc_method_handlers = { 99 | 'GetOperation': grpc.unary_unary_rpc_method_handler( 100 | servicer.GetOperation, 101 | request_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.GetOperationRequest.FromString, 102 | response_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.SerializeToString, 103 | ), 104 | 'WaitOperation': grpc.unary_unary_rpc_method_handler( 105 | servicer.WaitOperation, 106 | request_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WaitOperationRequest.FromString, 107 | response_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.SerializeToString, 108 | ), 109 | 'ListOperations': grpc.unary_unary_rpc_method_handler( 110 | servicer.ListOperations, 111 | request_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.ListOperationsRequest.FromString, 112 | response_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.ListOperationsResponse.SerializeToString, 113 | ), 114 | 'WatchOperations': grpc.unary_stream_rpc_method_handler( 115 | servicer.WatchOperations, 116 | request_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WatchOperationsRequest.FromString, 117 | response_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WatchOperationsResponse.SerializeToString, 118 | ), 119 | 'DeleteOperation': grpc.unary_unary_rpc_method_handler( 120 | servicer.DeleteOperation, 121 | request_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.DeleteOperationRequest.FromString, 122 | response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, 123 | ), 124 | 'CancelOperation': grpc.unary_unary_rpc_method_handler( 125 | servicer.CancelOperation, 126 | request_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.CancelOperationRequest.FromString, 127 | response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, 128 | ), 129 | } 130 | generic_handler = grpc.method_handlers_generic_handler( 131 | 'tinkoff.cloud.longrunning.v1.Operations', rpc_method_handlers) 132 | server.add_generic_rpc_handlers((generic_handler,)) 133 | 134 | 135 | # This class is part of an EXPERIMENTAL API. 136 | class Operations(object): 137 | """Missing associated documentation comment in .proto file.""" 138 | 139 | @staticmethod 140 | def GetOperation(request, 141 | target, 142 | options=(), 143 | channel_credentials=None, 144 | call_credentials=None, 145 | insecure=False, 146 | compression=None, 147 | wait_for_ready=None, 148 | timeout=None, 149 | metadata=None): 150 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.longrunning.v1.Operations/GetOperation', 151 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.GetOperationRequest.SerializeToString, 152 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.FromString, 153 | options, channel_credentials, 154 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 155 | 156 | @staticmethod 157 | def WaitOperation(request, 158 | target, 159 | options=(), 160 | channel_credentials=None, 161 | call_credentials=None, 162 | insecure=False, 163 | compression=None, 164 | wait_for_ready=None, 165 | timeout=None, 166 | metadata=None): 167 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.longrunning.v1.Operations/WaitOperation', 168 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WaitOperationRequest.SerializeToString, 169 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.FromString, 170 | options, channel_credentials, 171 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 172 | 173 | @staticmethod 174 | def ListOperations(request, 175 | target, 176 | options=(), 177 | channel_credentials=None, 178 | call_credentials=None, 179 | insecure=False, 180 | compression=None, 181 | wait_for_ready=None, 182 | timeout=None, 183 | metadata=None): 184 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.longrunning.v1.Operations/ListOperations', 185 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.ListOperationsRequest.SerializeToString, 186 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.ListOperationsResponse.FromString, 187 | options, channel_credentials, 188 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 189 | 190 | @staticmethod 191 | def WatchOperations(request, 192 | target, 193 | options=(), 194 | channel_credentials=None, 195 | call_credentials=None, 196 | insecure=False, 197 | compression=None, 198 | wait_for_ready=None, 199 | timeout=None, 200 | metadata=None): 201 | return grpc.experimental.unary_stream(request, target, '/tinkoff.cloud.longrunning.v1.Operations/WatchOperations', 202 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WatchOperationsRequest.SerializeToString, 203 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.WatchOperationsResponse.FromString, 204 | options, channel_credentials, 205 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 206 | 207 | @staticmethod 208 | def DeleteOperation(request, 209 | target, 210 | options=(), 211 | channel_credentials=None, 212 | call_credentials=None, 213 | insecure=False, 214 | compression=None, 215 | wait_for_ready=None, 216 | timeout=None, 217 | metadata=None): 218 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.longrunning.v1.Operations/DeleteOperation', 219 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.DeleteOperationRequest.SerializeToString, 220 | google_dot_protobuf_dot_empty__pb2.Empty.FromString, 221 | options, channel_credentials, 222 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 223 | 224 | @staticmethod 225 | def CancelOperation(request, 226 | target, 227 | options=(), 228 | channel_credentials=None, 229 | call_credentials=None, 230 | insecure=False, 231 | compression=None, 232 | wait_for_ready=None, 233 | timeout=None, 234 | metadata=None): 235 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.longrunning.v1.Operations/CancelOperation', 236 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.CancelOperationRequest.SerializeToString, 237 | google_dot_protobuf_dot_empty__pb2.Empty.FromString, 238 | options, channel_credentials, 239 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 240 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/stt/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/stt/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/stt/v1/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/stt/v1/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/stt/v1/stt_pb2_grpc.py: -------------------------------------------------------------------------------- 1 | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! 2 | """Client and server classes corresponding to protobuf-defined services.""" 3 | import grpc 4 | 5 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.longrunning.v1 import longrunning_pb2 as tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2 6 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.stt.v1 import stt_pb2 as tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2 7 | 8 | 9 | class SpeechToTextStub(object): 10 | """Missing associated documentation comment in .proto file.""" 11 | 12 | def __init__(self, channel): 13 | """Constructor. 14 | 15 | Args: 16 | channel: A grpc.Channel. 17 | """ 18 | self.Recognize = channel.unary_unary( 19 | '/tinkoff.cloud.stt.v1.SpeechToText/Recognize', 20 | request_serializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.RecognizeRequest.SerializeToString, 21 | response_deserializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.RecognizeResponse.FromString, 22 | ) 23 | self.StreamingRecognize = channel.stream_stream( 24 | '/tinkoff.cloud.stt.v1.SpeechToText/StreamingRecognize', 25 | request_serializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.StreamingRecognizeRequest.SerializeToString, 26 | response_deserializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.StreamingRecognizeResponse.FromString, 27 | ) 28 | self.LongRunningRecognize = channel.unary_unary( 29 | '/tinkoff.cloud.stt.v1.SpeechToText/LongRunningRecognize', 30 | request_serializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.LongRunningRecognizeRequest.SerializeToString, 31 | response_deserializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.FromString, 32 | ) 33 | 34 | 35 | class SpeechToTextServicer(object): 36 | """Missing associated documentation comment in .proto file.""" 37 | 38 | def Recognize(self, request, context): 39 | """Missing associated documentation comment in .proto file.""" 40 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 41 | context.set_details('Method not implemented!') 42 | raise NotImplementedError('Method not implemented!') 43 | 44 | def StreamingRecognize(self, request_iterator, context): 45 | """Missing associated documentation comment in .proto file.""" 46 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 47 | context.set_details('Method not implemented!') 48 | raise NotImplementedError('Method not implemented!') 49 | 50 | def LongRunningRecognize(self, request, context): 51 | """Missing associated documentation comment in .proto file.""" 52 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 53 | context.set_details('Method not implemented!') 54 | raise NotImplementedError('Method not implemented!') 55 | 56 | 57 | def add_SpeechToTextServicer_to_server(servicer, server): 58 | rpc_method_handlers = { 59 | 'Recognize': grpc.unary_unary_rpc_method_handler( 60 | servicer.Recognize, 61 | request_deserializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.RecognizeRequest.FromString, 62 | response_serializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.RecognizeResponse.SerializeToString, 63 | ), 64 | 'StreamingRecognize': grpc.stream_stream_rpc_method_handler( 65 | servicer.StreamingRecognize, 66 | request_deserializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.StreamingRecognizeRequest.FromString, 67 | response_serializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.StreamingRecognizeResponse.SerializeToString, 68 | ), 69 | 'LongRunningRecognize': grpc.unary_unary_rpc_method_handler( 70 | servicer.LongRunningRecognize, 71 | request_deserializer=tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.LongRunningRecognizeRequest.FromString, 72 | response_serializer=tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.SerializeToString, 73 | ), 74 | } 75 | generic_handler = grpc.method_handlers_generic_handler( 76 | 'tinkoff.cloud.stt.v1.SpeechToText', rpc_method_handlers) 77 | server.add_generic_rpc_handlers((generic_handler,)) 78 | 79 | 80 | # This class is part of an EXPERIMENTAL API. 81 | class SpeechToText(object): 82 | """Missing associated documentation comment in .proto file.""" 83 | 84 | @staticmethod 85 | def Recognize(request, 86 | target, 87 | options=(), 88 | channel_credentials=None, 89 | call_credentials=None, 90 | insecure=False, 91 | compression=None, 92 | wait_for_ready=None, 93 | timeout=None, 94 | metadata=None): 95 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.stt.v1.SpeechToText/Recognize', 96 | tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.RecognizeRequest.SerializeToString, 97 | tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.RecognizeResponse.FromString, 98 | options, channel_credentials, 99 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 100 | 101 | @staticmethod 102 | def StreamingRecognize(request_iterator, 103 | target, 104 | options=(), 105 | channel_credentials=None, 106 | call_credentials=None, 107 | insecure=False, 108 | compression=None, 109 | wait_for_ready=None, 110 | timeout=None, 111 | metadata=None): 112 | return grpc.experimental.stream_stream(request_iterator, target, '/tinkoff.cloud.stt.v1.SpeechToText/StreamingRecognize', 113 | tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.StreamingRecognizeRequest.SerializeToString, 114 | tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.StreamingRecognizeResponse.FromString, 115 | options, channel_credentials, 116 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 117 | 118 | @staticmethod 119 | def LongRunningRecognize(request, 120 | target, 121 | options=(), 122 | channel_credentials=None, 123 | call_credentials=None, 124 | insecure=False, 125 | compression=None, 126 | wait_for_ready=None, 127 | timeout=None, 128 | metadata=None): 129 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.stt.v1.SpeechToText/LongRunningRecognize', 130 | tinkoff_dot_cloud_dot_stt_dot_v1_dot_stt__pb2.LongRunningRecognizeRequest.SerializeToString, 131 | tinkoff_dot_cloud_dot_longrunning_dot_v1_dot_longrunning__pb2.Operation.FromString, 132 | options, channel_credentials, 133 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 134 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/tts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/tts/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/tts/v1/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinkoff/voicekit_client_python/bab98c375ec4c59053653bfd9aef9c35b863df88/tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/tts/v1/__init__.py -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/tts/v1/tts_pb2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! 3 | # source: tinkoff/cloud/tts/v1/tts.proto 4 | """Generated protocol buffer code.""" 5 | from google.protobuf.internal import enum_type_wrapper 6 | from google.protobuf import descriptor as _descriptor 7 | from google.protobuf import message as _message 8 | from google.protobuf import reflection as _reflection 9 | from google.protobuf import symbol_database as _symbol_database 10 | # @@protoc_insertion_point(imports) 11 | 12 | _sym_db = _symbol_database.Default() 13 | 14 | 15 | from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 16 | 17 | 18 | DESCRIPTOR = _descriptor.FileDescriptor( 19 | name='tinkoff/cloud/tts/v1/tts.proto', 20 | package='tinkoff.cloud.tts.v1', 21 | syntax='proto3', 22 | serialized_options=b'Z@stash.tcsbank.ru/stt/tinkoff_cloud_apis/pkg/tinkoff/cloud/tts/v1', 23 | create_key=_descriptor._internal_create_key, 24 | serialized_pb=b'\n\x1etinkoff/cloud/tts/v1/tts.proto\x12\x14tinkoff.cloud.tts.v1\x1a\x1cgoogle/api/annotations.proto\"\x8c\x01\n\x05Voice\x12\x16\n\x0elanguage_codes\x18\x01 \x03(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12:\n\x0bssml_gender\x18\x03 \x01(\x0e\x32%.tinkoff.cloud.tts.v1.SsmlVoiceGender\x12!\n\x19natural_sample_rate_hertz\x18\x04 \x01(\x05\"*\n\x11ListVoicesRequest\x12\x15\n\rlanguage_code\x18\x01 \x01(\t\"B\n\x13ListVoicesResponses\x12+\n\x06voices\x18\x01 \x03(\x0b\x32\x1b.tinkoff.cloud.tts.v1.Voice\"\xa5\x01\n\rTemplateInput\x12\x10\n\x08template\x18\x01 \x01(\t\x12=\n\x05slots\x18\x02 \x03(\x0b\x32..tinkoff.cloud.tts.v1.TemplateInput.SlotsEntry\x12\x15\n\rbackup_phrase\x18\x03 \x01(\t\x1a,\n\nSlotsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\",\n\x0eSynthesisInput\x12\x0c\n\x04text\x18\x01 \x01(\t\x12\x0c\n\x04ssml\x18\x02 \x01(\t\"w\n\x14VoiceSelectionParams\x12\x15\n\rlanguage_code\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12:\n\x0bssml_gender\x18\x03 \x01(\x0e\x32%.tinkoff.cloud.tts.v1.SsmlVoiceGender\"\x9f\x01\n\x0b\x41udioConfig\x12;\n\x0e\x61udio_encoding\x18\x01 \x01(\x0e\x32#.tinkoff.cloud.tts.v1.AudioEncoding\x12\x15\n\rspeaking_rate\x18\x02 \x01(\x01\x12\x19\n\x11sample_rate_hertz\x18\x05 \x01(\x05J\x04\x08\x03\x10\x04J\x04\x08\x04\x10\x05R\x05pitchR\x0evolume_gain_db\"\xff\x01\n\x17SynthesizeSpeechRequest\x12\x33\n\x05input\x18\x01 \x01(\x0b\x32$.tinkoff.cloud.tts.v1.SynthesisInput\x12\x39\n\x05voice\x18\x02 \x01(\x0b\x32*.tinkoff.cloud.tts.v1.VoiceSelectionParams\x12\x37\n\x0c\x61udio_config\x18\x03 \x01(\x0b\x32!.tinkoff.cloud.tts.v1.AudioConfig\x12;\n\x0etemplate_input\x18\x04 \x01(\x0b\x32#.tinkoff.cloud.tts.v1.TemplateInput\"1\n\x18SynthesizeSpeechResponse\x12\x15\n\raudio_content\x18\x01 \x01(\x0c\"8\n!StreamingSynthesizeSpeechResponse\x12\x13\n\x0b\x61udio_chunk\x18\x01 \x01(\x0c*W\n\x0fSsmlVoiceGender\x12!\n\x1dSSML_VOICE_GENDER_UNSPECIFIED\x10\x00\x12\x08\n\x04MALE\x10\x01\x12\n\n\x06\x46\x45MALE\x10\x02\x12\x0b\n\x07NEUTRAL\x10\x03*\xe0\x01\n\rAudioEncoding\x12\x18\n\x14\x45NCODING_UNSPECIFIED\x10\x00\x12\x0c\n\x08LINEAR16\x10\x01\x12\t\n\x05MULAW\x10\x03\x12\x08\n\x04\x41LAW\x10\x08\x12\r\n\tLINEAR32F\x10\t\x12\x0c\n\x08RAW_OPUS\x10\x0b\"\x04\x08\x02\x10\x02\"\x04\x08\x04\x10\x04\"\x04\x08\x05\x10\x05\"\x04\x08\x06\x10\x06\"\x04\x08\x07\x10\x07\"\x04\x08\n\x10\n\"\x04\x08\x0c\x10\x0c*\x04\x46LAC*\x03\x41MR*\x06\x41MR_WB*\x08OGG_OPUS*\x16SPEEX_WITH_HEADER_BYTE*\nOGG_VORBIS*\nMPEG_AUDIO2\x9b\x03\n\x0cTextToSpeech\x12}\n\nListVoices\x12\'.tinkoff.cloud.tts.v1.ListVoicesRequest\x1a).tinkoff.cloud.tts.v1.ListVoicesResponses\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/v1/tts:list_voices\x12\x8a\x01\n\nSynthesize\x12-.tinkoff.cloud.tts.v1.SynthesizeSpeechRequest\x1a..tinkoff.cloud.tts.v1.SynthesizeSpeechResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\"\x12/v1/tts:synthesize:\x01*\x12\x7f\n\x13StreamingSynthesize\x12-.tinkoff.cloud.tts.v1.SynthesizeSpeechRequest\x1a\x37.tinkoff.cloud.tts.v1.StreamingSynthesizeSpeechResponse0\x01\x42\x42Z@stash.tcsbank.ru/stt/tinkoff_cloud_apis/pkg/tinkoff/cloud/tts/v1b\x06proto3' 25 | , 26 | dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,]) 27 | 28 | _SSMLVOICEGENDER = _descriptor.EnumDescriptor( 29 | name='SsmlVoiceGender', 30 | full_name='tinkoff.cloud.tts.v1.SsmlVoiceGender', 31 | filename=None, 32 | file=DESCRIPTOR, 33 | create_key=_descriptor._internal_create_key, 34 | values=[ 35 | _descriptor.EnumValueDescriptor( 36 | name='SSML_VOICE_GENDER_UNSPECIFIED', index=0, number=0, 37 | serialized_options=None, 38 | type=None, 39 | create_key=_descriptor._internal_create_key), 40 | _descriptor.EnumValueDescriptor( 41 | name='MALE', index=1, number=1, 42 | serialized_options=None, 43 | type=None, 44 | create_key=_descriptor._internal_create_key), 45 | _descriptor.EnumValueDescriptor( 46 | name='FEMALE', index=2, number=2, 47 | serialized_options=None, 48 | type=None, 49 | create_key=_descriptor._internal_create_key), 50 | _descriptor.EnumValueDescriptor( 51 | name='NEUTRAL', index=3, number=3, 52 | serialized_options=None, 53 | type=None, 54 | create_key=_descriptor._internal_create_key), 55 | ], 56 | containing_type=None, 57 | serialized_options=None, 58 | serialized_start=1205, 59 | serialized_end=1292, 60 | ) 61 | _sym_db.RegisterEnumDescriptor(_SSMLVOICEGENDER) 62 | 63 | SsmlVoiceGender = enum_type_wrapper.EnumTypeWrapper(_SSMLVOICEGENDER) 64 | _AUDIOENCODING = _descriptor.EnumDescriptor( 65 | name='AudioEncoding', 66 | full_name='tinkoff.cloud.tts.v1.AudioEncoding', 67 | filename=None, 68 | file=DESCRIPTOR, 69 | create_key=_descriptor._internal_create_key, 70 | values=[ 71 | _descriptor.EnumValueDescriptor( 72 | name='ENCODING_UNSPECIFIED', index=0, number=0, 73 | serialized_options=None, 74 | type=None, 75 | create_key=_descriptor._internal_create_key), 76 | _descriptor.EnumValueDescriptor( 77 | name='LINEAR16', index=1, number=1, 78 | serialized_options=None, 79 | type=None, 80 | create_key=_descriptor._internal_create_key), 81 | _descriptor.EnumValueDescriptor( 82 | name='MULAW', index=2, number=3, 83 | serialized_options=None, 84 | type=None, 85 | create_key=_descriptor._internal_create_key), 86 | _descriptor.EnumValueDescriptor( 87 | name='ALAW', index=3, number=8, 88 | serialized_options=None, 89 | type=None, 90 | create_key=_descriptor._internal_create_key), 91 | _descriptor.EnumValueDescriptor( 92 | name='LINEAR32F', index=4, number=9, 93 | serialized_options=None, 94 | type=None, 95 | create_key=_descriptor._internal_create_key), 96 | _descriptor.EnumValueDescriptor( 97 | name='RAW_OPUS', index=5, number=11, 98 | serialized_options=None, 99 | type=None, 100 | create_key=_descriptor._internal_create_key), 101 | ], 102 | containing_type=None, 103 | serialized_options=None, 104 | serialized_start=1295, 105 | serialized_end=1519, 106 | ) 107 | _sym_db.RegisterEnumDescriptor(_AUDIOENCODING) 108 | 109 | AudioEncoding = enum_type_wrapper.EnumTypeWrapper(_AUDIOENCODING) 110 | SSML_VOICE_GENDER_UNSPECIFIED = 0 111 | MALE = 1 112 | FEMALE = 2 113 | NEUTRAL = 3 114 | ENCODING_UNSPECIFIED = 0 115 | LINEAR16 = 1 116 | MULAW = 3 117 | ALAW = 8 118 | LINEAR32F = 9 119 | RAW_OPUS = 11 120 | 121 | 122 | 123 | _VOICE = _descriptor.Descriptor( 124 | name='Voice', 125 | full_name='tinkoff.cloud.tts.v1.Voice', 126 | filename=None, 127 | file=DESCRIPTOR, 128 | containing_type=None, 129 | create_key=_descriptor._internal_create_key, 130 | fields=[ 131 | _descriptor.FieldDescriptor( 132 | name='language_codes', full_name='tinkoff.cloud.tts.v1.Voice.language_codes', index=0, 133 | number=1, type=9, cpp_type=9, label=3, 134 | has_default_value=False, default_value=[], 135 | message_type=None, enum_type=None, containing_type=None, 136 | is_extension=False, extension_scope=None, 137 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 138 | _descriptor.FieldDescriptor( 139 | name='name', full_name='tinkoff.cloud.tts.v1.Voice.name', index=1, 140 | number=2, type=9, cpp_type=9, label=1, 141 | has_default_value=False, default_value=b"".decode('utf-8'), 142 | message_type=None, enum_type=None, containing_type=None, 143 | is_extension=False, extension_scope=None, 144 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 145 | _descriptor.FieldDescriptor( 146 | name='ssml_gender', full_name='tinkoff.cloud.tts.v1.Voice.ssml_gender', index=2, 147 | number=3, type=14, cpp_type=8, label=1, 148 | has_default_value=False, default_value=0, 149 | message_type=None, enum_type=None, containing_type=None, 150 | is_extension=False, extension_scope=None, 151 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 152 | _descriptor.FieldDescriptor( 153 | name='natural_sample_rate_hertz', full_name='tinkoff.cloud.tts.v1.Voice.natural_sample_rate_hertz', index=3, 154 | number=4, type=5, cpp_type=1, label=1, 155 | has_default_value=False, default_value=0, 156 | message_type=None, enum_type=None, containing_type=None, 157 | is_extension=False, extension_scope=None, 158 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 159 | ], 160 | extensions=[ 161 | ], 162 | nested_types=[], 163 | enum_types=[ 164 | ], 165 | serialized_options=None, 166 | is_extendable=False, 167 | syntax='proto3', 168 | extension_ranges=[], 169 | oneofs=[ 170 | ], 171 | serialized_start=87, 172 | serialized_end=227, 173 | ) 174 | 175 | 176 | _LISTVOICESREQUEST = _descriptor.Descriptor( 177 | name='ListVoicesRequest', 178 | full_name='tinkoff.cloud.tts.v1.ListVoicesRequest', 179 | filename=None, 180 | file=DESCRIPTOR, 181 | containing_type=None, 182 | create_key=_descriptor._internal_create_key, 183 | fields=[ 184 | _descriptor.FieldDescriptor( 185 | name='language_code', full_name='tinkoff.cloud.tts.v1.ListVoicesRequest.language_code', index=0, 186 | number=1, type=9, cpp_type=9, label=1, 187 | has_default_value=False, default_value=b"".decode('utf-8'), 188 | message_type=None, enum_type=None, containing_type=None, 189 | is_extension=False, extension_scope=None, 190 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 191 | ], 192 | extensions=[ 193 | ], 194 | nested_types=[], 195 | enum_types=[ 196 | ], 197 | serialized_options=None, 198 | is_extendable=False, 199 | syntax='proto3', 200 | extension_ranges=[], 201 | oneofs=[ 202 | ], 203 | serialized_start=229, 204 | serialized_end=271, 205 | ) 206 | 207 | 208 | _LISTVOICESRESPONSES = _descriptor.Descriptor( 209 | name='ListVoicesResponses', 210 | full_name='tinkoff.cloud.tts.v1.ListVoicesResponses', 211 | filename=None, 212 | file=DESCRIPTOR, 213 | containing_type=None, 214 | create_key=_descriptor._internal_create_key, 215 | fields=[ 216 | _descriptor.FieldDescriptor( 217 | name='voices', full_name='tinkoff.cloud.tts.v1.ListVoicesResponses.voices', index=0, 218 | number=1, type=11, cpp_type=10, label=3, 219 | has_default_value=False, default_value=[], 220 | message_type=None, enum_type=None, containing_type=None, 221 | is_extension=False, extension_scope=None, 222 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 223 | ], 224 | extensions=[ 225 | ], 226 | nested_types=[], 227 | enum_types=[ 228 | ], 229 | serialized_options=None, 230 | is_extendable=False, 231 | syntax='proto3', 232 | extension_ranges=[], 233 | oneofs=[ 234 | ], 235 | serialized_start=273, 236 | serialized_end=339, 237 | ) 238 | 239 | 240 | _TEMPLATEINPUT_SLOTSENTRY = _descriptor.Descriptor( 241 | name='SlotsEntry', 242 | full_name='tinkoff.cloud.tts.v1.TemplateInput.SlotsEntry', 243 | filename=None, 244 | file=DESCRIPTOR, 245 | containing_type=None, 246 | create_key=_descriptor._internal_create_key, 247 | fields=[ 248 | _descriptor.FieldDescriptor( 249 | name='key', full_name='tinkoff.cloud.tts.v1.TemplateInput.SlotsEntry.key', index=0, 250 | number=1, type=9, cpp_type=9, label=1, 251 | has_default_value=False, default_value=b"".decode('utf-8'), 252 | message_type=None, enum_type=None, containing_type=None, 253 | is_extension=False, extension_scope=None, 254 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 255 | _descriptor.FieldDescriptor( 256 | name='value', full_name='tinkoff.cloud.tts.v1.TemplateInput.SlotsEntry.value', index=1, 257 | number=2, type=9, cpp_type=9, label=1, 258 | has_default_value=False, default_value=b"".decode('utf-8'), 259 | message_type=None, enum_type=None, containing_type=None, 260 | is_extension=False, extension_scope=None, 261 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 262 | ], 263 | extensions=[ 264 | ], 265 | nested_types=[], 266 | enum_types=[ 267 | ], 268 | serialized_options=b'8\001', 269 | is_extendable=False, 270 | syntax='proto3', 271 | extension_ranges=[], 272 | oneofs=[ 273 | ], 274 | serialized_start=463, 275 | serialized_end=507, 276 | ) 277 | 278 | _TEMPLATEINPUT = _descriptor.Descriptor( 279 | name='TemplateInput', 280 | full_name='tinkoff.cloud.tts.v1.TemplateInput', 281 | filename=None, 282 | file=DESCRIPTOR, 283 | containing_type=None, 284 | create_key=_descriptor._internal_create_key, 285 | fields=[ 286 | _descriptor.FieldDescriptor( 287 | name='template', full_name='tinkoff.cloud.tts.v1.TemplateInput.template', index=0, 288 | number=1, type=9, cpp_type=9, label=1, 289 | has_default_value=False, default_value=b"".decode('utf-8'), 290 | message_type=None, enum_type=None, containing_type=None, 291 | is_extension=False, extension_scope=None, 292 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 293 | _descriptor.FieldDescriptor( 294 | name='slots', full_name='tinkoff.cloud.tts.v1.TemplateInput.slots', index=1, 295 | number=2, type=11, cpp_type=10, label=3, 296 | has_default_value=False, default_value=[], 297 | message_type=None, enum_type=None, containing_type=None, 298 | is_extension=False, extension_scope=None, 299 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 300 | _descriptor.FieldDescriptor( 301 | name='backup_phrase', full_name='tinkoff.cloud.tts.v1.TemplateInput.backup_phrase', index=2, 302 | number=3, type=9, cpp_type=9, label=1, 303 | has_default_value=False, default_value=b"".decode('utf-8'), 304 | message_type=None, enum_type=None, containing_type=None, 305 | is_extension=False, extension_scope=None, 306 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 307 | ], 308 | extensions=[ 309 | ], 310 | nested_types=[_TEMPLATEINPUT_SLOTSENTRY, ], 311 | enum_types=[ 312 | ], 313 | serialized_options=None, 314 | is_extendable=False, 315 | syntax='proto3', 316 | extension_ranges=[], 317 | oneofs=[ 318 | ], 319 | serialized_start=342, 320 | serialized_end=507, 321 | ) 322 | 323 | 324 | _SYNTHESISINPUT = _descriptor.Descriptor( 325 | name='SynthesisInput', 326 | full_name='tinkoff.cloud.tts.v1.SynthesisInput', 327 | filename=None, 328 | file=DESCRIPTOR, 329 | containing_type=None, 330 | create_key=_descriptor._internal_create_key, 331 | fields=[ 332 | _descriptor.FieldDescriptor( 333 | name='text', full_name='tinkoff.cloud.tts.v1.SynthesisInput.text', index=0, 334 | number=1, type=9, cpp_type=9, label=1, 335 | has_default_value=False, default_value=b"".decode('utf-8'), 336 | message_type=None, enum_type=None, containing_type=None, 337 | is_extension=False, extension_scope=None, 338 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 339 | _descriptor.FieldDescriptor( 340 | name='ssml', full_name='tinkoff.cloud.tts.v1.SynthesisInput.ssml', index=1, 341 | number=2, type=9, cpp_type=9, label=1, 342 | has_default_value=False, default_value=b"".decode('utf-8'), 343 | message_type=None, enum_type=None, containing_type=None, 344 | is_extension=False, extension_scope=None, 345 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 346 | ], 347 | extensions=[ 348 | ], 349 | nested_types=[], 350 | enum_types=[ 351 | ], 352 | serialized_options=None, 353 | is_extendable=False, 354 | syntax='proto3', 355 | extension_ranges=[], 356 | oneofs=[ 357 | ], 358 | serialized_start=509, 359 | serialized_end=553, 360 | ) 361 | 362 | 363 | _VOICESELECTIONPARAMS = _descriptor.Descriptor( 364 | name='VoiceSelectionParams', 365 | full_name='tinkoff.cloud.tts.v1.VoiceSelectionParams', 366 | filename=None, 367 | file=DESCRIPTOR, 368 | containing_type=None, 369 | create_key=_descriptor._internal_create_key, 370 | fields=[ 371 | _descriptor.FieldDescriptor( 372 | name='language_code', full_name='tinkoff.cloud.tts.v1.VoiceSelectionParams.language_code', index=0, 373 | number=1, type=9, cpp_type=9, label=1, 374 | has_default_value=False, default_value=b"".decode('utf-8'), 375 | message_type=None, enum_type=None, containing_type=None, 376 | is_extension=False, extension_scope=None, 377 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 378 | _descriptor.FieldDescriptor( 379 | name='name', full_name='tinkoff.cloud.tts.v1.VoiceSelectionParams.name', index=1, 380 | number=2, type=9, cpp_type=9, label=1, 381 | has_default_value=False, default_value=b"".decode('utf-8'), 382 | message_type=None, enum_type=None, containing_type=None, 383 | is_extension=False, extension_scope=None, 384 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 385 | _descriptor.FieldDescriptor( 386 | name='ssml_gender', full_name='tinkoff.cloud.tts.v1.VoiceSelectionParams.ssml_gender', index=2, 387 | number=3, type=14, cpp_type=8, label=1, 388 | has_default_value=False, default_value=0, 389 | message_type=None, enum_type=None, containing_type=None, 390 | is_extension=False, extension_scope=None, 391 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 392 | ], 393 | extensions=[ 394 | ], 395 | nested_types=[], 396 | enum_types=[ 397 | ], 398 | serialized_options=None, 399 | is_extendable=False, 400 | syntax='proto3', 401 | extension_ranges=[], 402 | oneofs=[ 403 | ], 404 | serialized_start=555, 405 | serialized_end=674, 406 | ) 407 | 408 | 409 | _AUDIOCONFIG = _descriptor.Descriptor( 410 | name='AudioConfig', 411 | full_name='tinkoff.cloud.tts.v1.AudioConfig', 412 | filename=None, 413 | file=DESCRIPTOR, 414 | containing_type=None, 415 | create_key=_descriptor._internal_create_key, 416 | fields=[ 417 | _descriptor.FieldDescriptor( 418 | name='audio_encoding', full_name='tinkoff.cloud.tts.v1.AudioConfig.audio_encoding', index=0, 419 | number=1, type=14, cpp_type=8, label=1, 420 | has_default_value=False, default_value=0, 421 | message_type=None, enum_type=None, containing_type=None, 422 | is_extension=False, extension_scope=None, 423 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 424 | _descriptor.FieldDescriptor( 425 | name='speaking_rate', full_name='tinkoff.cloud.tts.v1.AudioConfig.speaking_rate', index=1, 426 | number=2, type=1, cpp_type=5, label=1, 427 | has_default_value=False, default_value=float(0), 428 | message_type=None, enum_type=None, containing_type=None, 429 | is_extension=False, extension_scope=None, 430 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 431 | _descriptor.FieldDescriptor( 432 | name='sample_rate_hertz', full_name='tinkoff.cloud.tts.v1.AudioConfig.sample_rate_hertz', index=2, 433 | number=5, type=5, cpp_type=1, label=1, 434 | has_default_value=False, default_value=0, 435 | message_type=None, enum_type=None, containing_type=None, 436 | is_extension=False, extension_scope=None, 437 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 438 | ], 439 | extensions=[ 440 | ], 441 | nested_types=[], 442 | enum_types=[ 443 | ], 444 | serialized_options=None, 445 | is_extendable=False, 446 | syntax='proto3', 447 | extension_ranges=[], 448 | oneofs=[ 449 | ], 450 | serialized_start=677, 451 | serialized_end=836, 452 | ) 453 | 454 | 455 | _SYNTHESIZESPEECHREQUEST = _descriptor.Descriptor( 456 | name='SynthesizeSpeechRequest', 457 | full_name='tinkoff.cloud.tts.v1.SynthesizeSpeechRequest', 458 | filename=None, 459 | file=DESCRIPTOR, 460 | containing_type=None, 461 | create_key=_descriptor._internal_create_key, 462 | fields=[ 463 | _descriptor.FieldDescriptor( 464 | name='input', full_name='tinkoff.cloud.tts.v1.SynthesizeSpeechRequest.input', index=0, 465 | number=1, type=11, cpp_type=10, label=1, 466 | has_default_value=False, default_value=None, 467 | message_type=None, enum_type=None, containing_type=None, 468 | is_extension=False, extension_scope=None, 469 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 470 | _descriptor.FieldDescriptor( 471 | name='voice', full_name='tinkoff.cloud.tts.v1.SynthesizeSpeechRequest.voice', index=1, 472 | number=2, type=11, cpp_type=10, label=1, 473 | has_default_value=False, default_value=None, 474 | message_type=None, enum_type=None, containing_type=None, 475 | is_extension=False, extension_scope=None, 476 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 477 | _descriptor.FieldDescriptor( 478 | name='audio_config', full_name='tinkoff.cloud.tts.v1.SynthesizeSpeechRequest.audio_config', index=2, 479 | number=3, type=11, cpp_type=10, label=1, 480 | has_default_value=False, default_value=None, 481 | message_type=None, enum_type=None, containing_type=None, 482 | is_extension=False, extension_scope=None, 483 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 484 | _descriptor.FieldDescriptor( 485 | name='template_input', full_name='tinkoff.cloud.tts.v1.SynthesizeSpeechRequest.template_input', index=3, 486 | number=4, type=11, cpp_type=10, label=1, 487 | has_default_value=False, default_value=None, 488 | message_type=None, enum_type=None, containing_type=None, 489 | is_extension=False, extension_scope=None, 490 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 491 | ], 492 | extensions=[ 493 | ], 494 | nested_types=[], 495 | enum_types=[ 496 | ], 497 | serialized_options=None, 498 | is_extendable=False, 499 | syntax='proto3', 500 | extension_ranges=[], 501 | oneofs=[ 502 | ], 503 | serialized_start=839, 504 | serialized_end=1094, 505 | ) 506 | 507 | 508 | _SYNTHESIZESPEECHRESPONSE = _descriptor.Descriptor( 509 | name='SynthesizeSpeechResponse', 510 | full_name='tinkoff.cloud.tts.v1.SynthesizeSpeechResponse', 511 | filename=None, 512 | file=DESCRIPTOR, 513 | containing_type=None, 514 | create_key=_descriptor._internal_create_key, 515 | fields=[ 516 | _descriptor.FieldDescriptor( 517 | name='audio_content', full_name='tinkoff.cloud.tts.v1.SynthesizeSpeechResponse.audio_content', index=0, 518 | number=1, type=12, cpp_type=9, label=1, 519 | has_default_value=False, default_value=b"", 520 | message_type=None, enum_type=None, containing_type=None, 521 | is_extension=False, extension_scope=None, 522 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 523 | ], 524 | extensions=[ 525 | ], 526 | nested_types=[], 527 | enum_types=[ 528 | ], 529 | serialized_options=None, 530 | is_extendable=False, 531 | syntax='proto3', 532 | extension_ranges=[], 533 | oneofs=[ 534 | ], 535 | serialized_start=1096, 536 | serialized_end=1145, 537 | ) 538 | 539 | 540 | _STREAMINGSYNTHESIZESPEECHRESPONSE = _descriptor.Descriptor( 541 | name='StreamingSynthesizeSpeechResponse', 542 | full_name='tinkoff.cloud.tts.v1.StreamingSynthesizeSpeechResponse', 543 | filename=None, 544 | file=DESCRIPTOR, 545 | containing_type=None, 546 | create_key=_descriptor._internal_create_key, 547 | fields=[ 548 | _descriptor.FieldDescriptor( 549 | name='audio_chunk', full_name='tinkoff.cloud.tts.v1.StreamingSynthesizeSpeechResponse.audio_chunk', index=0, 550 | number=1, type=12, cpp_type=9, label=1, 551 | has_default_value=False, default_value=b"", 552 | message_type=None, enum_type=None, containing_type=None, 553 | is_extension=False, extension_scope=None, 554 | serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), 555 | ], 556 | extensions=[ 557 | ], 558 | nested_types=[], 559 | enum_types=[ 560 | ], 561 | serialized_options=None, 562 | is_extendable=False, 563 | syntax='proto3', 564 | extension_ranges=[], 565 | oneofs=[ 566 | ], 567 | serialized_start=1147, 568 | serialized_end=1203, 569 | ) 570 | 571 | _VOICE.fields_by_name['ssml_gender'].enum_type = _SSMLVOICEGENDER 572 | _LISTVOICESRESPONSES.fields_by_name['voices'].message_type = _VOICE 573 | _TEMPLATEINPUT_SLOTSENTRY.containing_type = _TEMPLATEINPUT 574 | _TEMPLATEINPUT.fields_by_name['slots'].message_type = _TEMPLATEINPUT_SLOTSENTRY 575 | _VOICESELECTIONPARAMS.fields_by_name['ssml_gender'].enum_type = _SSMLVOICEGENDER 576 | _AUDIOCONFIG.fields_by_name['audio_encoding'].enum_type = _AUDIOENCODING 577 | _SYNTHESIZESPEECHREQUEST.fields_by_name['input'].message_type = _SYNTHESISINPUT 578 | _SYNTHESIZESPEECHREQUEST.fields_by_name['voice'].message_type = _VOICESELECTIONPARAMS 579 | _SYNTHESIZESPEECHREQUEST.fields_by_name['audio_config'].message_type = _AUDIOCONFIG 580 | _SYNTHESIZESPEECHREQUEST.fields_by_name['template_input'].message_type = _TEMPLATEINPUT 581 | DESCRIPTOR.message_types_by_name['Voice'] = _VOICE 582 | DESCRIPTOR.message_types_by_name['ListVoicesRequest'] = _LISTVOICESREQUEST 583 | DESCRIPTOR.message_types_by_name['ListVoicesResponses'] = _LISTVOICESRESPONSES 584 | DESCRIPTOR.message_types_by_name['TemplateInput'] = _TEMPLATEINPUT 585 | DESCRIPTOR.message_types_by_name['SynthesisInput'] = _SYNTHESISINPUT 586 | DESCRIPTOR.message_types_by_name['VoiceSelectionParams'] = _VOICESELECTIONPARAMS 587 | DESCRIPTOR.message_types_by_name['AudioConfig'] = _AUDIOCONFIG 588 | DESCRIPTOR.message_types_by_name['SynthesizeSpeechRequest'] = _SYNTHESIZESPEECHREQUEST 589 | DESCRIPTOR.message_types_by_name['SynthesizeSpeechResponse'] = _SYNTHESIZESPEECHRESPONSE 590 | DESCRIPTOR.message_types_by_name['StreamingSynthesizeSpeechResponse'] = _STREAMINGSYNTHESIZESPEECHRESPONSE 591 | DESCRIPTOR.enum_types_by_name['SsmlVoiceGender'] = _SSMLVOICEGENDER 592 | DESCRIPTOR.enum_types_by_name['AudioEncoding'] = _AUDIOENCODING 593 | _sym_db.RegisterFileDescriptor(DESCRIPTOR) 594 | 595 | Voice = _reflection.GeneratedProtocolMessageType('Voice', (_message.Message,), { 596 | 'DESCRIPTOR' : _VOICE, 597 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 598 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.Voice) 599 | }) 600 | _sym_db.RegisterMessage(Voice) 601 | 602 | ListVoicesRequest = _reflection.GeneratedProtocolMessageType('ListVoicesRequest', (_message.Message,), { 603 | 'DESCRIPTOR' : _LISTVOICESREQUEST, 604 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 605 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.ListVoicesRequest) 606 | }) 607 | _sym_db.RegisterMessage(ListVoicesRequest) 608 | 609 | ListVoicesResponses = _reflection.GeneratedProtocolMessageType('ListVoicesResponses', (_message.Message,), { 610 | 'DESCRIPTOR' : _LISTVOICESRESPONSES, 611 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 612 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.ListVoicesResponses) 613 | }) 614 | _sym_db.RegisterMessage(ListVoicesResponses) 615 | 616 | TemplateInput = _reflection.GeneratedProtocolMessageType('TemplateInput', (_message.Message,), { 617 | 618 | 'SlotsEntry' : _reflection.GeneratedProtocolMessageType('SlotsEntry', (_message.Message,), { 619 | 'DESCRIPTOR' : _TEMPLATEINPUT_SLOTSENTRY, 620 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 621 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.TemplateInput.SlotsEntry) 622 | }) 623 | , 624 | 'DESCRIPTOR' : _TEMPLATEINPUT, 625 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 626 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.TemplateInput) 627 | }) 628 | _sym_db.RegisterMessage(TemplateInput) 629 | _sym_db.RegisterMessage(TemplateInput.SlotsEntry) 630 | 631 | SynthesisInput = _reflection.GeneratedProtocolMessageType('SynthesisInput', (_message.Message,), { 632 | 'DESCRIPTOR' : _SYNTHESISINPUT, 633 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 634 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.SynthesisInput) 635 | }) 636 | _sym_db.RegisterMessage(SynthesisInput) 637 | 638 | VoiceSelectionParams = _reflection.GeneratedProtocolMessageType('VoiceSelectionParams', (_message.Message,), { 639 | 'DESCRIPTOR' : _VOICESELECTIONPARAMS, 640 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 641 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.VoiceSelectionParams) 642 | }) 643 | _sym_db.RegisterMessage(VoiceSelectionParams) 644 | 645 | AudioConfig = _reflection.GeneratedProtocolMessageType('AudioConfig', (_message.Message,), { 646 | 'DESCRIPTOR' : _AUDIOCONFIG, 647 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 648 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.AudioConfig) 649 | }) 650 | _sym_db.RegisterMessage(AudioConfig) 651 | 652 | SynthesizeSpeechRequest = _reflection.GeneratedProtocolMessageType('SynthesizeSpeechRequest', (_message.Message,), { 653 | 'DESCRIPTOR' : _SYNTHESIZESPEECHREQUEST, 654 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 655 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.SynthesizeSpeechRequest) 656 | }) 657 | _sym_db.RegisterMessage(SynthesizeSpeechRequest) 658 | 659 | SynthesizeSpeechResponse = _reflection.GeneratedProtocolMessageType('SynthesizeSpeechResponse', (_message.Message,), { 660 | 'DESCRIPTOR' : _SYNTHESIZESPEECHRESPONSE, 661 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 662 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.SynthesizeSpeechResponse) 663 | }) 664 | _sym_db.RegisterMessage(SynthesizeSpeechResponse) 665 | 666 | StreamingSynthesizeSpeechResponse = _reflection.GeneratedProtocolMessageType('StreamingSynthesizeSpeechResponse', (_message.Message,), { 667 | 'DESCRIPTOR' : _STREAMINGSYNTHESIZESPEECHRESPONSE, 668 | '__module__' : 'tinkoff.cloud.tts.v1.tts_pb2' 669 | # @@protoc_insertion_point(class_scope:tinkoff.cloud.tts.v1.StreamingSynthesizeSpeechResponse) 670 | }) 671 | _sym_db.RegisterMessage(StreamingSynthesizeSpeechResponse) 672 | 673 | 674 | DESCRIPTOR._options = None 675 | _TEMPLATEINPUT_SLOTSENTRY._options = None 676 | 677 | _TEXTTOSPEECH = _descriptor.ServiceDescriptor( 678 | name='TextToSpeech', 679 | full_name='tinkoff.cloud.tts.v1.TextToSpeech', 680 | file=DESCRIPTOR, 681 | index=0, 682 | serialized_options=None, 683 | create_key=_descriptor._internal_create_key, 684 | serialized_start=1522, 685 | serialized_end=1933, 686 | methods=[ 687 | _descriptor.MethodDescriptor( 688 | name='ListVoices', 689 | full_name='tinkoff.cloud.tts.v1.TextToSpeech.ListVoices', 690 | index=0, 691 | containing_service=None, 692 | input_type=_LISTVOICESREQUEST, 693 | output_type=_LISTVOICESRESPONSES, 694 | serialized_options=b'\202\323\344\223\002\025\022\023/v1/tts:list_voices', 695 | create_key=_descriptor._internal_create_key, 696 | ), 697 | _descriptor.MethodDescriptor( 698 | name='Synthesize', 699 | full_name='tinkoff.cloud.tts.v1.TextToSpeech.Synthesize', 700 | index=1, 701 | containing_service=None, 702 | input_type=_SYNTHESIZESPEECHREQUEST, 703 | output_type=_SYNTHESIZESPEECHRESPONSE, 704 | serialized_options=b'\202\323\344\223\002\027\"\022/v1/tts:synthesize:\001*', 705 | create_key=_descriptor._internal_create_key, 706 | ), 707 | _descriptor.MethodDescriptor( 708 | name='StreamingSynthesize', 709 | full_name='tinkoff.cloud.tts.v1.TextToSpeech.StreamingSynthesize', 710 | index=2, 711 | containing_service=None, 712 | input_type=_SYNTHESIZESPEECHREQUEST, 713 | output_type=_STREAMINGSYNTHESIZESPEECHRESPONSE, 714 | serialized_options=None, 715 | create_key=_descriptor._internal_create_key, 716 | ), 717 | ]) 718 | _sym_db.RegisterServiceDescriptor(_TEXTTOSPEECH) 719 | 720 | DESCRIPTOR.services_by_name['TextToSpeech'] = _TEXTTOSPEECH 721 | 722 | # @@protoc_insertion_point(module_scope) 723 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/apis/tinkoff/cloud/tts/v1/tts_pb2_grpc.py: -------------------------------------------------------------------------------- 1 | # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! 2 | """Client and server classes corresponding to protobuf-defined services.""" 3 | import grpc 4 | 5 | from tinkoff_voicekit_client.speech_utils.apis.tinkoff.cloud.tts.v1 import tts_pb2 as tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2 6 | 7 | 8 | class TextToSpeechStub(object): 9 | """Missing associated documentation comment in .proto file.""" 10 | 11 | def __init__(self, channel): 12 | """Constructor. 13 | 14 | Args: 15 | channel: A grpc.Channel. 16 | """ 17 | self.ListVoices = channel.unary_unary( 18 | '/tinkoff.cloud.tts.v1.TextToSpeech/ListVoices', 19 | request_serializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.ListVoicesRequest.SerializeToString, 20 | response_deserializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.ListVoicesResponses.FromString, 21 | ) 22 | self.Synthesize = channel.unary_unary( 23 | '/tinkoff.cloud.tts.v1.TextToSpeech/Synthesize', 24 | request_serializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechRequest.SerializeToString, 25 | response_deserializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechResponse.FromString, 26 | ) 27 | self.StreamingSynthesize = channel.unary_stream( 28 | '/tinkoff.cloud.tts.v1.TextToSpeech/StreamingSynthesize', 29 | request_serializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechRequest.SerializeToString, 30 | response_deserializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.StreamingSynthesizeSpeechResponse.FromString, 31 | ) 32 | 33 | 34 | class TextToSpeechServicer(object): 35 | """Missing associated documentation comment in .proto file.""" 36 | 37 | def ListVoices(self, request, context): 38 | """Missing associated documentation comment in .proto file.""" 39 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 40 | context.set_details('Method not implemented!') 41 | raise NotImplementedError('Method not implemented!') 42 | 43 | def Synthesize(self, request, context): 44 | """Missing associated documentation comment in .proto file.""" 45 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 46 | context.set_details('Method not implemented!') 47 | raise NotImplementedError('Method not implemented!') 48 | 49 | def StreamingSynthesize(self, request, context): 50 | """Missing associated documentation comment in .proto file.""" 51 | context.set_code(grpc.StatusCode.UNIMPLEMENTED) 52 | context.set_details('Method not implemented!') 53 | raise NotImplementedError('Method not implemented!') 54 | 55 | 56 | def add_TextToSpeechServicer_to_server(servicer, server): 57 | rpc_method_handlers = { 58 | 'ListVoices': grpc.unary_unary_rpc_method_handler( 59 | servicer.ListVoices, 60 | request_deserializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.ListVoicesRequest.FromString, 61 | response_serializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.ListVoicesResponses.SerializeToString, 62 | ), 63 | 'Synthesize': grpc.unary_unary_rpc_method_handler( 64 | servicer.Synthesize, 65 | request_deserializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechRequest.FromString, 66 | response_serializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechResponse.SerializeToString, 67 | ), 68 | 'StreamingSynthesize': grpc.unary_stream_rpc_method_handler( 69 | servicer.StreamingSynthesize, 70 | request_deserializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechRequest.FromString, 71 | response_serializer=tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.StreamingSynthesizeSpeechResponse.SerializeToString, 72 | ), 73 | } 74 | generic_handler = grpc.method_handlers_generic_handler( 75 | 'tinkoff.cloud.tts.v1.TextToSpeech', rpc_method_handlers) 76 | server.add_generic_rpc_handlers((generic_handler,)) 77 | 78 | 79 | # This class is part of an EXPERIMENTAL API. 80 | class TextToSpeech(object): 81 | """Missing associated documentation comment in .proto file.""" 82 | 83 | @staticmethod 84 | def ListVoices(request, 85 | target, 86 | options=(), 87 | channel_credentials=None, 88 | call_credentials=None, 89 | insecure=False, 90 | compression=None, 91 | wait_for_ready=None, 92 | timeout=None, 93 | metadata=None): 94 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.tts.v1.TextToSpeech/ListVoices', 95 | tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.ListVoicesRequest.SerializeToString, 96 | tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.ListVoicesResponses.FromString, 97 | options, channel_credentials, 98 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 99 | 100 | @staticmethod 101 | def Synthesize(request, 102 | target, 103 | options=(), 104 | channel_credentials=None, 105 | call_credentials=None, 106 | insecure=False, 107 | compression=None, 108 | wait_for_ready=None, 109 | timeout=None, 110 | metadata=None): 111 | return grpc.experimental.unary_unary(request, target, '/tinkoff.cloud.tts.v1.TextToSpeech/Synthesize', 112 | tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechRequest.SerializeToString, 113 | tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechResponse.FromString, 114 | options, channel_credentials, 115 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 116 | 117 | @staticmethod 118 | def StreamingSynthesize(request, 119 | target, 120 | options=(), 121 | channel_credentials=None, 122 | call_credentials=None, 123 | insecure=False, 124 | compression=None, 125 | wait_for_ready=None, 126 | timeout=None, 127 | metadata=None): 128 | return grpc.experimental.unary_stream(request, target, '/tinkoff.cloud.tts.v1.TextToSpeech/StreamingSynthesize', 129 | tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.SynthesizeSpeechRequest.SerializeToString, 130 | tinkoff_dot_cloud_dot_tts_dot_v1_dot_tts__pb2.StreamingSynthesizeSpeechResponse.FromString, 131 | options, channel_credentials, 132 | insecure, call_credentials, compression, wait_for_ready, timeout, metadata) 133 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/config_data.py: -------------------------------------------------------------------------------- 1 | """ 2 | This file consider config parameters for authorization to server VoiceKit 3 | """ 4 | 5 | MAX_LENGTH = 32 * 10**6 6 | CHUNK_SIZE = 8192 7 | 8 | language_code = "ru-RU" 9 | 10 | client_config = { 11 | "host_stt": "api.tinkoff.ai", 12 | "host_tts": "api.tinkoff.ai", 13 | "host_operations": "api.tinkoff.ai", 14 | "port": 443 15 | } 16 | 17 | aud = { 18 | "stt": "tinkoff.cloud.stt", 19 | "tts": "tinkoff.cloud.tts", 20 | "operations": "tinkoff.cloud.longrunning" 21 | } 22 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/infrastructure.py: -------------------------------------------------------------------------------- 1 | import io 2 | import os 3 | 4 | from google.protobuf.json_format import MessageToDict 5 | 6 | 7 | def get_buffer(source): 8 | if type(source) is str and os.path.isfile(source): 9 | with open(source, "rb") as f: 10 | buffer = f.read() 11 | return io.BytesIO(buffer) 12 | elif isinstance(source, io.BufferedReader): 13 | return source 14 | elif isinstance(source, io.BytesIO): 15 | return source 16 | else: 17 | raise ValueError("Incorrect source parameters: must be path to file or io.BufferedReader") 18 | 19 | 20 | def response_format(response, dict_format, response_metadata=None): 21 | if dict_format: 22 | _response = MessageToDict( 23 | response, 24 | including_default_value_fields=True, 25 | preserving_proto_field_name=True 26 | ) 27 | else: 28 | _response = response 29 | 30 | if response_metadata: 31 | return _response, response_metadata 32 | return _response 33 | 34 | 35 | def dict_generator(responses, dict_format): 36 | if dict_format: 37 | for response in responses: 38 | yield MessageToDict( 39 | response, 40 | including_default_value_fields=True, 41 | preserving_proto_field_name=True 42 | ) 43 | else: 44 | for response in responses: 45 | yield response 46 | 47 | 48 | async def aio_dict_generator(responses, dict_format): 49 | if dict_format: 50 | async for response in responses: 51 | yield MessageToDict( 52 | response, 53 | including_default_value_fields=True, 54 | preserving_proto_field_name=True 55 | ) 56 | else: 57 | async for response in responses: 58 | yield response 59 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/metadata.py: -------------------------------------------------------------------------------- 1 | import copy 2 | from time import time 3 | import hmac 4 | import json 5 | import base64 6 | 7 | 8 | class Metadata: 9 | _TEN_MINUTES = 600 10 | 11 | _AUTH_PAYLOAD = { 12 | "iss": "best_issuer", 13 | "sub": "best_user", 14 | "aud": None 15 | } 16 | 17 | _HEADER = { 18 | "alg": "HS256", 19 | "typ": "JWT", 20 | "kid": None 21 | } 22 | 23 | def __init__(self, api_key: str, secret_key: str, aud: str): 24 | self._aud = aud 25 | self._api_key = api_key 26 | self._secret_key = secret_key 27 | jwt = self._create_jwt(api_key, secret_key) 28 | metadata = [ 29 | ["authorization", "Bearer {0}".format(jwt)], 30 | ["x-api-key", api_key], 31 | ] 32 | 33 | self._metadata = metadata 34 | 35 | def _create_jwt(self, api_key: str, secret_key: str): 36 | header = copy.deepcopy(Metadata._HEADER) 37 | header["kid"] = api_key 38 | 39 | auth_payload = copy.deepcopy(Metadata._AUTH_PAYLOAD) 40 | auth_payload["aud"] = self._aud 41 | self._expiration_time = int(time()) + Metadata._TEN_MINUTES 42 | auth_payload["exp"] = self._expiration_time 43 | 44 | payload_bytes = json.dumps(auth_payload, separators=(',', ':')).encode("utf-8") 45 | header_bytes = json.dumps(header, separators=(',', ':')).encode("utf-8") 46 | payload_base64 = base64.urlsafe_b64encode(payload_bytes) 47 | header_base64 = base64.urlsafe_b64encode(header_bytes) 48 | 49 | data = header_base64 + b"." + payload_base64 50 | signature_bytes = hmac.new(base64.urlsafe_b64decode(self._pad_base64(secret_key)), 51 | msg=data, 52 | digestmod="sha256") 53 | signature = base64.urlsafe_b64encode(signature_bytes.digest()) 54 | 55 | jwt = data + b"." + signature 56 | return jwt.decode("utf-8") 57 | 58 | def _pad_base64(self, base64_str): 59 | num_equals_signs = 4 - len(base64_str) % 4 60 | return base64_str + '=' * num_equals_signs 61 | 62 | def is_fresh_jwt(self): 63 | return self._expiration_time > int(time()) 64 | 65 | def refresh_jwt(self): 66 | api_key = self._metadata[1][1] 67 | self._metadata[0][1] = "Bearer {0}".format(self._create_jwt(api_key, self._secret_key)) 68 | 69 | @property 70 | def metadata(self): 71 | if not self.is_fresh_jwt(): 72 | self.refresh_jwt() 73 | return self._metadata 74 | -------------------------------------------------------------------------------- /tinkoff_voicekit_client/speech_utils/user_utils.py: -------------------------------------------------------------------------------- 1 | 2 | def get_x_request_id(metadata): 3 | """ 4 | Returning x-request-id from response metadata 5 | :param metadata: response metadata from one of VoiceKit methods 6 | return: None if x-request-id don't contain in metadata 7 | """ 8 | x_request_id = tuple(filter(lambda x: x[0] == 'x-request-id', metadata)) 9 | if x_request_id: 10 | x_request_id = x_request_id[0][1] 11 | return x_request_id 12 | return None 13 | --------------------------------------------------------------------------------