Jayashree Sridhar
commited on
Commit
·
3019028
1
Parent(s):
0f20f6a
added privateattr from pydantic
Browse files
agents/tools/voice_tools.py
CHANGED
|
@@ -7,7 +7,7 @@ import os
|
|
| 7 |
import tempfile
|
| 8 |
import soundfile as sf
|
| 9 |
import torch
|
| 10 |
-
|
| 11 |
from crewai.tools import BaseTool
|
| 12 |
|
| 13 |
|
|
@@ -136,9 +136,10 @@ class TranscribeAudioTool(BaseTool):
|
|
| 136 |
name: str = "transcribe_audio"
|
| 137 |
description: str = "Transcribe audio to text and detect language."
|
| 138 |
model_config = {"arbitrary_types_allowed": True}
|
|
|
|
| 139 |
def __init__(self, config=None):
|
| 140 |
super().__init__()
|
| 141 |
-
self.
|
| 142 |
def _run(self, audio_data: List[float], language: Optional[str] = None):
|
| 143 |
audio_np = np.array(audio_data, dtype=np.float32)
|
| 144 |
text, detected_lang = asyncio.run(self.vp.transcribe(audio_np, language))
|
|
|
|
| 7 |
import tempfile
|
| 8 |
import soundfile as sf
|
| 9 |
import torch
|
| 10 |
+
from pydantic import PrivateAttr
|
| 11 |
from crewai.tools import BaseTool
|
| 12 |
|
| 13 |
|
|
|
|
| 136 |
name: str = "transcribe_audio"
|
| 137 |
description: str = "Transcribe audio to text and detect language."
|
| 138 |
model_config = {"arbitrary_types_allowed": True}
|
| 139 |
+
_vp: MultilingualVoiceProcessor = PrivateAttr()
|
| 140 |
def __init__(self, config=None):
|
| 141 |
super().__init__()
|
| 142 |
+
self._vp = MultilingualVoiceProcessor()
|
| 143 |
def _run(self, audio_data: List[float], language: Optional[str] = None):
|
| 144 |
audio_np = np.array(audio_data, dtype=np.float32)
|
| 145 |
text, detected_lang = asyncio.run(self.vp.transcribe(audio_np, language))
|