Compare commits
2 Commits
693472186d
...
63b9d0c3db
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63b9d0c3db | ||
|
|
5ba28d859c |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.mbp
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: nigzu.com.maubot-stt
|
id: nigzu.com.maubot-stt
|
||||||
version: 0.3.0
|
version: 0.3.1
|
||||||
license: MIT
|
license: MIT
|
||||||
modules:
|
modules:
|
||||||
- openai-whisper
|
- openai-whisper
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ from mautrix.errors import MatrixRequestError
|
|||||||
from mautrix.types import EventType, MessageType, RelationType, TextMessageEventContent, Format,RelatesTo,InReplyTo
|
from mautrix.types import EventType, MessageType, RelationType, TextMessageEventContent, Format,RelatesTo,InReplyTo
|
||||||
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
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):
|
class Config(BaseProxyConfig):
|
||||||
def do_update(self, helper: ConfigUpdateHelper) -> None:
|
def do_update(self, helper: ConfigUpdateHelper) -> None:
|
||||||
helper.copy("whisper_endpoint")
|
helper.copy("whisper_endpoint")
|
||||||
@@ -46,6 +49,9 @@ class WhisperPlugin(Plugin):
|
|||||||
if self.allowed_rooms and event.room_id not in self.allowed_rooms:
|
if self.allowed_rooms and event.room_id not in self.allowed_rooms:
|
||||||
return False
|
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
|
return event.content.msgtype == MessageType.AUDIO or event.content.msgtype == MessageType.FILE
|
||||||
|
|
||||||
@event.on(EventType.ROOM_MESSAGE)
|
@event.on(EventType.ROOM_MESSAGE)
|
||||||
@@ -57,8 +63,6 @@ class WhisperPlugin(Plugin):
|
|||||||
await event.mark_read()
|
await event.mark_read()
|
||||||
await self.client.set_typing(event.room_id, timeout=99999)
|
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)
|
audio_bytes = await self.client.download_media(url=event.content.url)
|
||||||
transcription = await self.transcribe_audio(audio_bytes)
|
transcription = await self.transcribe_audio(audio_bytes)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user