nimroddolev / chime_tts

A custom Home Assistant integration to play combined audio files before and/or after text-to-speech (TTS) messages
https://nimroddolev.github.io/chime_tts/
MIT License
147 stars 12 forks source link

Warnings in Log "Detected blocking call to open inside the event loop by custom integration 'chime_tts' " #146

Closed JCummings49 closed 2 weeks ago

JCummings49 commented 2 weeks ago

System Health details

System Information

version core-2024.6.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.2
os_name Linux
os_version 6.6.29-haos
arch aarch64
timezone America/Chicago
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.34.0 Stage | running Available Repositories | 1392 Downloaded Repositories | 24 HACS Data | ok
AccuWeather can_reach_server | ok -- | -- remaining_requests | 49
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | March 5, 2025 at 6:00 PM relayer_connected | true relayer_region | us-east-1 remote_enabled | true remote_connected | true alexa_enabled | true google_enabled | false remote_server | us-east-1-8.ui.nabu.casa certificate_status | ready instance_id | aa0b917ef61c4654a670573e45e1e118 can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.3 -- | -- update_channel | stable supervisor_version | supervisor-2024.06.0 agent_version | 1.6.0 docker_version | 25.0.5 disk_total | 234.7 GB disk_used | 10.4 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | odroid-m1 supervisor_api | ok version_api | ok installed_addons | Terminal & SSH (9.14.0), File editor (5.8.0), Matter Server (6.1.2), ESPHome (2024.5.5), Studio Code Server (5.15.0), MariaDB (2.7.1), Samba share (12.3.1), Mosquitto broker (6.4.1), Samba Backup (5.2.0)
Dashboards dashboards | 6 -- | -- resources | 16 views | 13 mode | storage
Recorder oldest_recorder_run | June 8, 2024 at 6:43 PM -- | -- current_recorder_run | June 12, 2024 at 6:56 PM estimated_db_size | 302.31 MiB database_engine | mysql database_version | 10.11.6

Checklist

Describe the issue

Getting Warning Log entries each time Chime TTS is used in an automation:

Logger: homeassistant.util.loop Source: util/loop.py:84 First occurred: 7:00:00 PM (4 occurrences) Last logged: 7:00:02 PM

Detected blocking call to open inside the event loop by custom integration 'chime_tts' at custom_components/chime_tts/init.py, line 1051: audio_from_path = AudioSegment.from_file(filepath) (offender: /usr/local/lib/python3.12/site-packages/pydub/utils.py, line 60: fd = open(fd, mode=mode)), please create a bug report at https://github.com/nimroddolev/chime_tts/issues

Reproduction steps

1. 2. 3. ...

Debug logs

Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 7:00:00 PM (4 occurrences)
Last logged: 7:00:02 PM

Detected blocking call to open inside the event loop by custom integration 'chime_tts' at custom_components/chime_tts/__init__.py, line 1051: audio_from_path = AudioSegment.from_file(filepath) (offender: /usr/local/lib/python3.12/site-packages/pydub/utils.py, line 60: fd = open(fd, mode=mode)), please create a bug report at https://github.com/nimroddolev/chime_tts/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/config/custom_components/chime_tts/queue_manager.py", line 33, in async_process_queue result = await asyncio.wait_for( File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut File "/config/custom_components/chime_tts/__init__.py", line 140, in async_say_execute audio_dict = await async_get_playback_audio_path(params, options) File "/config/custom_components/chime_tts/__init__.py", line 770, in async_get_playback_audio_path output_audio = await async_get_audio_from_path(hass=hass, File "/config/custom_components/chime_tts/__init__.py", line 1051, in async_get_audio_from_path audio_from_path = AudioSegment.from_file(filepath)
Detected blocking call to open inside the event loop by custom integration 'chime_tts' at custom_components/chime_tts/helpers/filesystem.py, line 119: audio.export(audio_full_path, format="mp3") (offender: /usr/local/lib/python3.12/site-packages/pydub/utils.py, line 60: fd = open(fd, mode=mode)), please create a bug report at https://github.com/nimroddolev/chime_tts/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/config/custom_components/chime_tts/queue_manager.py", line 33, in async_process_queue result = await asyncio.wait_for( File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut File "/config/custom_components/chime_tts/__init__.py", line 140, in async_say_execute audio_dict = await async_get_playback_audio_path(params, options) File "/config/custom_components/chime_tts/__init__.py", line 797, in async_get_playback_audio_path new_audio_file = filesystem_helper.save_audio_to_folder(output_audio, _data.get(initial_save_folder_key, None)) File "/config/custom_components/chime_tts/helpers/filesystem.py", line 119, in save_audio_to_folder audio.export(audio_full_path, format="mp3")
Detected blocking call to open inside the event loop by custom integration 'chime_tts' at custom_components/chime_tts/helpers/filesystem.py, line 119: audio.export(audio_full_path, format="mp3") (offender: /usr/local/lib/python3.12/site-packages/pydub/audio_segment.py, line 962: with open(os.devnull, 'rb') as devnull:), please create a bug report at https://github.com/nimroddolev/chime_tts/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/config/custom_components/chime_tts/queue_manager.py", line 33, in async_process_queue result = await asyncio.wait_for( File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut File "/config/custom_components/chime_tts/__init__.py", line 140, in async_say_execute audio_dict = await async_get_playback_audio_path(params, options) File "/config/custom_components/chime_tts/__init__.py", line 797, in async_get_playback_audio_path new_audio_file = filesystem_helper.save_audio_to_folder(output_audio, _data.get(initial_save_folder_key, None)) File "/config/custom_components/chime_tts/helpers/filesystem.py", line 119, in save_audio_to_folder audio.export(audio_full_path, format="mp3")
Detected blocking call to open inside the event loop by custom integration 'chime_tts' at custom_components/chime_tts/__init__.py, line 813: duration = len(AudioSegment.from_file(new_audio_file)) / 1000.0 (offender: /usr/local/lib/python3.12/site-packages/pydub/utils.py, line 60: fd = open(fd, mode=mode)), please create a bug report at https://github.com/nimroddolev/chime_tts/issues Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> sys.exit(main()) File "/usr/src/homeassistant/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/config/custom_components/chime_tts/queue_manager.py", line 33, in async_process_queue result = await asyncio.wait_for( File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for return await fut File "/config/custom_components/chime_tts/__init__.py", line 140, in async_say_execute audio_dict = await async_get_playback_audio_path(params, options) File "/config/custom_components/chime_tts/__init__.py", line 813, in async_get_playback_audio_path duration = len(AudioSegment.from_file(new_audio_file)) / 1000.0

Diagnostics dump

I have the output of diagnostics on a linux machine, but I can't figure out how to upload it to here. Seemingly cut and paste doesn't work. Draging the file here only results in the path to the file on the machine.

nimroddolev commented 2 weeks ago

This issue appears to be a duplicate of https://github.com/nimroddolev/chime_tts/issues/136, which has been resolved in the beta releases and will be released in the upcoming stable release.