diff --git a/maubot.yaml b/maubot.yaml index 769d3f1..da48eba 100644 --- a/maubot.yaml +++ b/maubot.yaml @@ -1,6 +1,6 @@ maubot: 0.1.0 id: nigzu.com.maubot-stt -version: 0.3.0 +version: 0.3.1 license: MIT modules: - openai-whisper diff --git a/nigzu.com.maubot-stt-v0.3.0.mbp b/nigzu.com.maubot-stt-v0.3.0.mbp new file mode 100644 index 0000000..5feb2f6 Binary files /dev/null and b/nigzu.com.maubot-stt-v0.3.0.mbp differ diff --git a/openai-whisper.py b/openai-whisper.py index 9065f6f..6a3e600 100644 --- a/openai-whisper.py +++ b/openai-whisper.py @@ -12,6 +12,9 @@ from mautrix.errors import MatrixRequestError from mautrix.types import EventType, MessageType, RelationType, TextMessageEventContent, Format,RelatesTo,InReplyTo from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper +ALLOWED_EXTENSIONS = ['flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm'] +ALLOWED_MIME_TYPES = ['audio/flac','audio/mp4','video/mpeg','audio/ogg','audio/wav','video/webm'] + class Config(BaseProxyConfig): def do_update(self, helper: ConfigUpdateHelper) -> None: helper.copy("whisper_endpoint") @@ -45,6 +48,9 @@ class WhisperPlugin(Plugin): if self.allowed_rooms and event.room_id not in self.allowed_rooms: return False + + if event.content.info.mimetype not in ALLOWED_MIME_TYPES: + return False return event.content.msgtype == MessageType.AUDIO or event.content.msgtype == MessageType.FILE @@ -56,8 +62,6 @@ class WhisperPlugin(Plugin): try: await event.mark_read() await self.client.set_typing(event.room_id, timeout=99999) - - self.log.error(event) audio_bytes = await self.client.download_media(url=event.content.url) transcription = await self.transcribe_audio(audio_bytes)