Spaces:
Sleeping
Sleeping
Download agentcourse_unit4/tools/audio_transcriber.py from mrpe24/Final_Assignment_Template: direct link, hf CLI and curl.
- Browser
- Download file 730 Bytes
-
https://huggingface.co/spaces/mrpe24/Final_Assignment_Template/resolve/main/agentcourse_unit4/tools/audio_transcriber.py
- Command line
-
hf download hf://spaces/mrpe24/Final_Assignment_Template/agentcourse_unit4/tools/audio_transcriber.py
-
curl -L -o audio_transcriber.py https://huggingface.co/spaces/mrpe24/Final_Assignment_Template/resolve/main/agentcourse_unit4/tools/audio_transcriber.py
730 Bytes
| from smolagents import Tool | |
| import whisper | |
| class AudioTranscriberTool(Tool): | |
| name = "audio_transcriber" | |
| description = (""" | |
| This is a tool that get the transcription of the audio file in the form of text. | |
| Supported file extensions: .mp3, .wav, .flac, .ogg, .m4a. | |
| """) | |
| inputs = { | |
| "file_path": { | |
| "type": "string", | |
| "description": "The file path to the audio file.", | |
| } | |
| } | |
| output_type = "string" | |
| def __init__(self, *args, **kwargs): | |
| super().__init__(*args, **kwargs) | |
| self.model = whisper.load_model("base") | |
| def forward(self, file_path: str) -> str: | |
| result = self.model.transcribe(file_path) | |
| return result['text'] | |