Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default voice id as fallback in get_tts_audio #123624

Merged

Conversation

sorgfresser
Copy link
Contributor

Proposed change

We fallback to default voice id if voice is not set in options dict passed to get_tts_audio.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the [development checklist][dev-checklist]
  • I have followed the [perfect PR recommendations][perfect-pr]
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

@@ -100,7 +100,7 @@ async def async_get_tts_audio(
"""Load tts audio file from the engine."""
_LOGGER.debug("Getting TTS audio for %s", message)
_LOGGER.debug("Options: %s", options)
voice_id = options[ATTR_VOICE]
voice_id = options.get(ATTR_VOICE, self._default_voice_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we already always have voice set during setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean default_voice_id? It is a string that is set in init, so before the Entity is passed to async_add_entities. I verified the test I added failed beforehand and works now and I can't manage to run into the #123597 issue with this branch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean ATTR_VOICE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. We're setting CONF_VOICE during setup, ATTR_VOICE is injected in the prepare_text_to_speech method of a PipelineRun, but only if the voice is set by the user. Since this isn't the case in the automation that raised the issue, we need the .get() here

@joostlek joostlek added this to the 2024.9.2 milestone Sep 10, 2024
@joostlek joostlek merged commit dd08a65 into home-assistant:dev Sep 10, 2024
26 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error on load
4 participants