From 7fee4c62c21f2d0031f1e1b4e345d19b5f8c06d3 Mon Sep 17 00:00:00 2001 From: Gad Akuka Date: Mon, 24 Feb 2025 19:17:06 +0200 Subject: [PATCH] Using the correct mime type --- custom_components/stream_assist/core/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/stream_assist/core/__init__.py b/custom_components/stream_assist/core/__init__.py index 4d7b5ab..2effdf2 100644 --- a/custom_components/stream_assist/core/__init__.py +++ b/custom_components/stream_assist/core/__init__.py @@ -1,6 +1,7 @@ import asyncio import logging from typing import Callable +import mimetypes from homeassistant.components import assist_pipeline from homeassistant.components import media_player @@ -125,7 +126,10 @@ def internal_event_callback(event: PipelineEvent): if event.type == PipelineEventType.STT_START: if player_entity_id and (media_id := data.get("stt_start_media")): - play_media(hass, player_entity_id, media_id, "audio") + mime_type, _ = mimetypes.guess_type(media_id) + if not mime_type: + mime_type = "audio" # Default to audio if mime type cannot be guessed + play_media(hass, player_entity_id, media_id, mime_type) elif event.type == PipelineEventType.TTS_END: if player_entity_id: tts = event.data["tts_output"]