> ## Documentation Index
> Fetch the complete documentation index at: https://docs.camel-ai.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Camel.models.base audio model

<a id="camel.models.base_audio_model" />

<a id="camel.models.base_audio_model.BaseAudioModel" />

## BaseAudioModel

```python theme={"system"}
class BaseAudioModel(ABC):
```

Base class for audio models providing Text-to-Speech (TTS) and
Speech-to-Text (STT) functionality.

<a id="camel.models.base_audio_model.BaseAudioModel.__init__" />

### **init**

```python theme={"system"}
def __init__(
    self,
    api_key: Optional[str] = None,
    url: Optional[str] = None,
    timeout: Optional[float] = Constants.TIMEOUT_THRESHOLD
):
```

Initialize an instance of BaseAudioModel.

**Parameters:**

* **api\_key** (Optional\[str]): API key for the audio service. If not provided, will look for an environment variable specific to the implementation.
* **url** (Optional\[str]): Base URL for the audio API. If not provided, will use a default URL or look for an environment variable specific to the implementation.
* **timeout** (Optional\[float], optional): The timeout value in seconds for API calls. If not provided, will fall back to the MODEL\_TIMEOUT environment variable or default to 180 seconds. (default: :obj:`None`)

<a id="camel.models.base_audio_model.BaseAudioModel.text_to_speech" />

### text\_to\_speech

```python theme={"system"}
def text_to_speech(self, input: str, **kwargs: Any):
```

Convert text to speech.

**Parameters:**

* **input** (str): The text to be converted to speech.
* **storage\_path** (str): The local path to store the generated speech file. \*\*kwargs (Any): Extra kwargs passed to the TTS API.

**Returns:**

Any: The response from the TTS API, which may vary by
implementation.

<a id="camel.models.base_audio_model.BaseAudioModel.speech_to_text" />

### speech\_to\_text

```python theme={"system"}
def speech_to_text(self, audio_file_path: str, **kwargs: Any):
```

Convert speech audio to text.

**Parameters:**

* **audio\_file\_path** (str): The audio file path to transcribe. \*\*kwargs (Any): Extra keyword arguments passed to the Speech-to-Text (STT) API.

**Returns:**

str: The transcribed text.

<a id="camel.models.base_audio_model.BaseAudioModel._ensure_directory_exists" />

### \_ensure\_directory\_exists

```python theme={"system"}
def _ensure_directory_exists(self, file_path: str):
```

Ensure the directory for the given file path exists.

**Parameters:**

* **file\_path** (str): The file path for which to ensure the directory exists.
