Skip to content

Your lightweight open-source personal agent.

feat(feishu): add audio transcription support using Groq Whisper

chengyongru215360113fa9
diff --git a/nanobot/channels/feishu.py b/nanobot/channels/feishu.py
index 8f69c0952..611c95e18 100644
--- a/nanobot/channels/feishu.py
+++ b/nanobot/channels/feishu.py
@@ -244,9 +244,10 @@ class FeishuChannel(BaseChannel):
name = "feishu"
- def __init__(self, config: FeishuConfig, bus: MessageBus):
+ def __init__(self, config: FeishuConfig, bus: MessageBus, groq_api_key: str = ""):
super().__init__(config, bus)
self.config: FeishuConfig = config
+ self.groq_api_key = groq_api_key
self._client: Any = None
self._ws_client: Any = None
self._ws_thread: threading.Thread | None = None
@@ -909,6 +910,18 @@ class FeishuChannel(BaseChannel):
file_path, content_text = await self._download_and_save_media(msg_type, content_json, message_id)
if file_path:
media_paths.append(file_path)
+
+ # Transcribe audio using Groq Whisper
+ if msg_type == "audio" and file_path and self.groq_api_key:
+ try:
+ from nanobot.providers.transcription import GroqTranscriptionProvider
+ transcriber = GroqTranscriptionProvider(api_key=self.groq_api_key)
+ transcription = await transcriber.transcribe(file_path)
+ if transcription:
+ content_text = f"[transcription: {transcription}]"
+ except Exception as e:
+ logger.warning("Failed to transcribe audio: {}", e)
+
content_parts.append(content_text)
elif msg_type in ("share_chat", "share_user", "interactive", "share_calendar_event", "system", "merge_forward"):
diff --git a/nanobot/channels/manager.py b/nanobot/channels/manager.py
index 7d7d11065..51539dd2d 100644
--- a/nanobot/channels/manager.py
+++ b/nanobot/channels/manager.py
@@ -74,7 +74,8 @@ class ChannelManager:
try:
from nanobot.channels.feishu import FeishuChannel
self.channels["feishu"] = FeishuChannel(
- self.config.channels.feishu, self.bus
+ self.config.channels.feishu, self.bus,
+ groq_api_key=self.config.providers.groq.api_key,
)
logger.info("Feishu channel enabled")
except ImportError as e: