mygitphase's picture
Add files using upload-large-folder tool
5b6b230 verified
# This file was auto-generated by Fern from our API Definition.
import typing
from .. import core
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.pronunciation_dictionary_data import PronunciationDictionaryData
from ..types.pronunciation_dictionary_delete_response import PronunciationDictionaryDeleteResponse
from ..types.pronunciation_dictionary_get_response import PronunciationDictionaryGetResponse
from ..types.pronunciation_dictionary_response import PronunciationDictionaryResponse
from ..types.pronunciation_dictionary_update_response import PronunciationDictionaryUpdateResponse
from .raw_client import AsyncRawPronunciationDictionaryClient, RawPronunciationDictionaryClient
# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)
class PronunciationDictionaryClient:
def __init__(self, *, client_wrapper: SyncClientWrapper):
self._raw_client = RawPronunciationDictionaryClient(client_wrapper=client_wrapper)
@property
def with_raw_response(self) -> RawPronunciationDictionaryClient:
"""
Retrieves a raw implementation of this client that returns raw responses.
Returns
-------
RawPronunciationDictionaryClient
"""
return self._raw_client
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> PronunciationDictionaryGetResponse:
"""
Retrieve a list of all pronunciation dictionary IDs associated with the authenticated user.
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryGetResponse
Successful Response
Examples
--------
from sarvamai import SarvamAI
client = SarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
client.pronunciation_dictionary.list()
"""
_response = self._raw_client.list(request_options=request_options)
return _response.data
def create(
self, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryResponse:
"""
Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples.
The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket).
**Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size.
Parameters
----------
file : core.File
See core.File for more documentation
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryResponse
Successful Response
Examples
--------
from sarvamai import SarvamAI
client = SarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
client.pronunciation_dictionary.create()
"""
_response = self._raw_client.create(file=file, request_options=request_options)
return _response.data
def update(
self, *, dict_id: str, file: core.File, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryUpdateResponse:
"""
Update an existing pronunciation dictionary by uploading a JSON file. You can add new words, change existing pronunciations, or both — entries not included in the uploaded file remain unchanged.
**Limits:** Max 100 words per dictionary, 1 MB file size.
The response includes the `dictionary_id` and the updated pronunciation mappings for verification.
Parameters
----------
dict_id : str
ID of the dictionary to update
file : core.File
See core.File for more documentation
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryUpdateResponse
Successful Response
Examples
--------
from sarvamai import SarvamAI
client = SarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
client.pronunciation_dictionary.update(
dict_id="dict_id",
)
"""
_response = self._raw_client.update(dict_id=dict_id, file=file, request_options=request_options)
return _response.data
def delete(
self, *, dict_id: str, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryDeleteResponse:
"""
Delete a pronunciation dictionary by its ID. Once deleted, the dictionary can no longer be referenced in text-to-speech requests.
Parameters
----------
dict_id : str
ID of the dictionary to delete
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryDeleteResponse
Successful Response
Examples
--------
from sarvamai import SarvamAI
client = SarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
client.pronunciation_dictionary.delete(
dict_id="dict_id",
)
"""
_response = self._raw_client.delete(dict_id=dict_id, request_options=request_options)
return _response.data
def get(
self, dict_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryData:
"""
Retrieve the full pronunciation mappings for a specific dictionary by its ID.
Returns the pronunciation data organized by language code, where each language contains word-to-pronunciation pairs.
Parameters
----------
dict_id : str
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryData
Successful Response
Examples
--------
from sarvamai import SarvamAI
client = SarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
client.pronunciation_dictionary.get(
dict_id="dict_id",
)
"""
_response = self._raw_client.get(dict_id, request_options=request_options)
return _response.data
class AsyncPronunciationDictionaryClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._raw_client = AsyncRawPronunciationDictionaryClient(client_wrapper=client_wrapper)
@property
def with_raw_response(self) -> AsyncRawPronunciationDictionaryClient:
"""
Retrieves a raw implementation of this client that returns raw responses.
Returns
-------
AsyncRawPronunciationDictionaryClient
"""
return self._raw_client
async def list(
self, *, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryGetResponse:
"""
Retrieve a list of all pronunciation dictionary IDs associated with the authenticated user.
Parameters
----------
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryGetResponse
Successful Response
Examples
--------
import asyncio
from sarvamai import AsyncSarvamAI
client = AsyncSarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
async def main() -> None:
await client.pronunciation_dictionary.list()
asyncio.run(main())
"""
_response = await self._raw_client.list(request_options=request_options)
return _response.data
async def create(
self, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryResponse:
"""
Upload a `.json` file to create a new pronunciation dictionary. Only supported by **bulbul:v3**.
The file should contain a JSON object with a `pronunciations` key mapping language codes to word-pronunciation pairs. See the [Pronunciation Dictionary guide](/api-reference-docs/api-guides-tutorials/text-to-speech/pronunciation-dictionary) for format details and examples.
The returned `dictionary_id` can be passed as `dict_id` in text-to-speech requests (REST, HTTP Stream, and WebSocket).
**Limits:** Max 10 dictionaries per user, 100 words per dictionary, 1 MB file size.
Parameters
----------
file : core.File
See core.File for more documentation
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryResponse
Successful Response
Examples
--------
import asyncio
from sarvamai import AsyncSarvamAI
client = AsyncSarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
async def main() -> None:
await client.pronunciation_dictionary.create()
asyncio.run(main())
"""
_response = await self._raw_client.create(file=file, request_options=request_options)
return _response.data
async def update(
self, *, dict_id: str, file: core.File, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryUpdateResponse:
"""
Update an existing pronunciation dictionary by uploading a JSON file. You can add new words, change existing pronunciations, or both — entries not included in the uploaded file remain unchanged.
**Limits:** Max 100 words per dictionary, 1 MB file size.
The response includes the `dictionary_id` and the updated pronunciation mappings for verification.
Parameters
----------
dict_id : str
ID of the dictionary to update
file : core.File
See core.File for more documentation
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryUpdateResponse
Successful Response
Examples
--------
import asyncio
from sarvamai import AsyncSarvamAI
client = AsyncSarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
async def main() -> None:
await client.pronunciation_dictionary.update(
dict_id="dict_id",
)
asyncio.run(main())
"""
_response = await self._raw_client.update(dict_id=dict_id, file=file, request_options=request_options)
return _response.data
async def delete(
self, *, dict_id: str, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryDeleteResponse:
"""
Delete a pronunciation dictionary by its ID. Once deleted, the dictionary can no longer be referenced in text-to-speech requests.
Parameters
----------
dict_id : str
ID of the dictionary to delete
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryDeleteResponse
Successful Response
Examples
--------
import asyncio
from sarvamai import AsyncSarvamAI
client = AsyncSarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
async def main() -> None:
await client.pronunciation_dictionary.delete(
dict_id="dict_id",
)
asyncio.run(main())
"""
_response = await self._raw_client.delete(dict_id=dict_id, request_options=request_options)
return _response.data
async def get(
self, dict_id: str, *, request_options: typing.Optional[RequestOptions] = None
) -> PronunciationDictionaryData:
"""
Retrieve the full pronunciation mappings for a specific dictionary by its ID.
Returns the pronunciation data organized by language code, where each language contains word-to-pronunciation pairs.
Parameters
----------
dict_id : str
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
PronunciationDictionaryData
Successful Response
Examples
--------
import asyncio
from sarvamai import AsyncSarvamAI
client = AsyncSarvamAI(
api_subscription_key="YOUR_API_SUBSCRIPTION_KEY",
)
async def main() -> None:
await client.pronunciation_dictionary.get(
dict_id="dict_id",
)
asyncio.run(main())
"""
_response = await self._raw_client.get(dict_id, request_options=request_options)
return _response.data