Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

2.8 KB
Raw Blame
<a id="camel.toolkits.audio_analysis_toolkit"></a>

<a id="camel.toolkits.audio_analysis_toolkit.download_file"></a>

## download_file

```python
def download_file(url: str, cache_dir: str):
```

Download a file from a URL to a local cache directory.

**Parameters:**

- **url** (str): The URL of the file to download.
- **cache_dir** (str): The directory to save the downloaded file.

**Returns:**

  str: The path to the downloaded file.

**Raises:**

- **Exception**: If the download fails.

<a id="camel.toolkits.audio_analysis_toolkit.AudioAnalysisToolkit"></a>

## AudioAnalysisToolkit

```python
class AudioAnalysisToolkit(BaseToolkit):
```

<a id="camel.toolkits.audio_analysis_toolkit.AudioAnalysisToolkit.__init__"></a>

### __init__

```python
def __init__(
    self,
    cache_dir: Optional[str] = None,
    transcribe_model: Optional[BaseAudioModel] = None,
    audio_reasoning_model: Optional[BaseModelBackend] = None,
    timeout: Optional[float] = None
):
```

A toolkit for audio processing and analysis. This class provides
methods for processing, transcribing, and extracting information from
audio data, including direct question answering about audio content.

**Parameters:**

- **cache_dir** (Optional[str]): Directory path for caching downloaded audio files. If not provided, 'tmp/' will be used. (default: :obj:`None`)
- **transcribe_model** (Optional[BaseAudioModel]): Model used for audio transcription. If not provided, OpenAIAudioModels will be used. (default: :obj:`None`)
- **audio_reasoning_model** (Optional[BaseModelBackend]): Model used for audio reasoning and question answering. If not provided, uses the default model from ChatAgent. (default: :obj:`None`)
- **timeout** (Optional[float]): The timeout value for API requests in seconds. If None, no timeout is applied. (default: :obj:`None`)

<a id="camel.toolkits.audio_analysis_toolkit.AudioAnalysisToolkit.audio2text"></a>

### audio2text

```python
def audio2text(self, audio_path: str):
```

Transcribe audio to text.

**Parameters:**

- **audio_path** (str): The path to the audio file or URL.

**Returns:**

  str: The transcribed text.

<a id="camel.toolkits.audio_analysis_toolkit.AudioAnalysisToolkit.ask_question_about_audio"></a>

### ask_question_about_audio

```python
def ask_question_about_audio(self, audio_path: str, question: str):
```

Ask any question about the audio and get the answer using
multimodal model.

**Parameters:**

- **audio_path** (str): The path to the audio file.
- **question** (str): The question to ask about the audio.

**Returns:**

  str: The answer to the question.

<a id="camel.toolkits.audio_analysis_toolkit.AudioAnalysisToolkit.get_tools"></a>

### get_tools

```python
def get_tools(self):
```

**Returns:**

  List[FunctionTool]: A list of FunctionTool objects representing the
functions in the toolkit.