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

Add TTS to media browser #11679

Merged
merged 2 commits into from Feb 14, 2022
Merged

Add TTS to media browser #11679

merged 2 commits into from Feb 14, 2022

Conversation

balloob
Copy link
Member

@balloob balloob commented Feb 13, 2022

Breaking change

Proposed change

Add TTS to media source. It shows a form to craft a message. Requires home-assistant/core#66483

image

For Home Assistant Cloud also shows the options:

image

When you change an option, it offers user also option to set the new combination as their default.

image

Once approved we can replace the cloud TTS try dialog with this implementation too.

Type of change

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

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

Comment on lines -249 to -251
: currentItem.children?.length
? childrenMediaClass.layout === "grid"
? html`
Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved the "no items" case up to get rid of a nested ternary statement.

@@ -186,10 +186,3 @@ export const updateCloudAlexaEntityConfig = (
entity_id: entityId,
...values,
});

export interface CloudTTSInfo {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to a new cloud/tts.ts file

@@ -100,61 +103,9 @@ export class CloudTTSPref extends LitElement {
}
}

private getLanguages = memoizeOne((info?: CloudTTSInfo) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this to cloud/tts.ts to make reusable.

@@ -219,18 +219,18 @@ class PanelMediaBrowser extends LitElement {
return;
}

if (item.media_content_type.startsWith("audio/")) {
const resolvedUrl = await resolveMediaSource(
Copy link
Member Author

Choose a reason for hiding this comment

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

We now always resolve the URL, because only the resolved URL can tell us correctly what content type it is. Noticed because TTS providers don't tell their mime type until you generate the file.

@@ -269,10 +269,6 @@ class PanelMediaBrowser extends LitElement {
return [
haStyle,
css`
:host {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what this was doing besides messing up my button styling.

)}
</button>
`
: html`<span></span>`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
: html`<span></span>`}
: html``}

Copy link
Member Author

Choose a reason for hiding this comment

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

It's on purpose to get flexbox to treat it as a child. Else the say button will jump from left to the right

@balloob balloob merged commit a321432 into dev Feb 14, 2022
@balloob balloob deleted the tts-media branch February 14, 2022 15:50
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2022
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.

None yet

3 participants