Spaces:
Sleeping
Sleeping
File size: 730 Bytes
d75dae7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
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']
|