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

feat: Adding more natural sounding voices to phone calls #2575

Conversation

AlaricWhitney
Copy link
Collaborator

@AlaricWhitney AlaricWhitney commented Aug 18, 2022

  • Identified the issue which this PR solves.
  • Read the CONTRIBUTING document.
  • Code builds clean without any errors or warnings.
  • Added appropriate tests for any new functionality.
  • All new and existing tests passed.
  • Added comments in the code, where necessary.
  • Ran make check to catch common errors. Fixed any that came up.

Description:
This PR updates the application to have be able to set the Twilio Phone call language and Text To Speech engine.

  • Currently the default language is "" (which Twilio interprets as us-EN). This PR allows you to adjust it to whatever you need.
  • Currently the default TTS engine is Twilio Basic Man, which sounds like a robot. This PR allows you to adjust it to whatever you need.
  • The greeting is also adjusted to make it more natural sounding by adjusting the verbiage, and adding a pause between the greeting and the alert message.

Which issue(s) this PR fixes:
Fixes #2574
Fixes #2576

Out of Scope:
NA

Screenshots:
NA

Describe any introduced user-facing changes:
By default, nothing changes for the user, however the user does have the new ability to change the TTS voice engine and the language for phone calls.

Describe any introduced API changes:
NA

Additional Info:
NA

config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
notification/twilio/twiml.go Outdated Show resolved Hide resolved
notification/twilio/voice.go Outdated Show resolved Hide resolved
notification/twilio/voice.go Outdated Show resolved Hide resolved
Copy link
Member

@mastercactapus mastercactapus left a comment

Choose a reason for hiding this comment

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

I'm going to look into using the XML encoder to deal with the escaping issue (as a separate PR), I already started some of that with the mocktwilio refactor work, so I think it will be straightforward.

config/config_test.go Outdated Show resolved Hide resolved
notification/twilio/twiml.go Outdated Show resolved Hide resolved
notification/twilio/twiml_test.go Outdated Show resolved Hide resolved
notification/twilio/voice.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
@AlaricWhitney
Copy link
Collaborator Author

@mastercactapus Cool. I'll wait until your XML PR #2582 goes in before making more updates to this PR.

@mastercactapus
Copy link
Member

@AlaricWhitney the XML PR has been merged

@stale
Copy link

stale bot commented Nov 12, 2022

This pull request has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the stale This is inactive label Nov 12, 2022
@mastercactapus
Copy link
Member

@AlaricWhitney, just a note on this, I haven't had a chance to dig in, but it doesn't seem to work with the Polly voices. The <break> blocks get read out literally. I think it all needs to be wrapped in <speak> or something like that to use the "advanced" syntax (I forget the acronym)

@stale stale bot removed the stale This is inactive label Nov 28, 2022
@AlaricWhitney
Copy link
Collaborator Author

@mastercactapus This is ready for review again. I've implemented the message to include an extra optional query parameter that indicates where in the string slice to insert pauses. I've also added unit tests and benchmark tests to show how it works. I also moved some of the message functionality into their own separate functions to make unit testing easier.

Copy link
Member

@mastercactapus mastercactapus left a comment

Choose a reason for hiding this comment

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

Having to manage/track indexes all over the place is going to be error-prone and noisy; we should be using a slice of strings throughout our application code to manage chunks of text.

The request itself can have the slice encoded in a string + []int format, but we should parse that as soon as we get the request into a more usable format of []string, and only switch to indexes at the last moment when we build the URL.

Doing so will let us simplify a lot of this.

notification/twilio/voice.go Outdated Show resolved Hide resolved
notification/twilio/voice.go Outdated Show resolved Hide resolved
notification/twilio/voice.go Outdated Show resolved Hide resolved
switch call.Digits {
default:
resp.SayUnknownDigit()
fallthrough
case "", digitRepeat:
resp.Say(call.msgBody)
processSayBody(resp, call.msgBody, call.msgPauseIndex)
Copy link
Member

Choose a reason for hiding this comment

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

This feels like it should just be a method

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can do it if you want, although I do think since it's voice specific, so I will make it part of the Voice object.

notification/twilio/voice_test.go Outdated Show resolved Hide resolved
@AlaricWhitney
Copy link
Collaborator Author

Having to manage/track indexes all over the place is going to be error-prone and noisy; we should be using a slice of strings throughout our application code to manage chunks of text.

The request itself can have the slice encoded in a string + []int format, but we should parse that as soon as we get the request into a more usable format of []string, and only switch to indexes at the last moment when we build the URL.

Doing so will let us simplify a lot of this.

I chose to do it this way to ensure separation of functionality between what each object is supposed to do, and ensure backwards compatibility. More specifically, I really think that the message injection processing should occur immediately next to where the message is defined. Indexes are ordered, so it shouldn't be an issue to pass it around a little bit.

mastercactapus
mastercactapus previously approved these changes Jan 12, 2023
Copy link
Collaborator

@tony-tvu tony-tvu left a comment

Choose a reason for hiding this comment

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

Everything is working fine but I'm seeing these logs fatal: No names found, cannot describe anything. which I'm not seeing when running on master branch. Is anyone else seeing this on their on when running on this branch?

Screenshot 2023-01-25 at 10 45 15 AM

@Forfold
Copy link
Contributor

Forfold commented Feb 2, 2023

Testing this now and not running into that @tony-tvu 🤔 Was this right after running make start, or after performing some action?

config/config.go Show resolved Hide resolved
config/config.go Show resolved Hide resolved
@AlaricWhitney
Copy link
Collaborator Author

@tony-tvu I'm seeing that as well. When I looked it up, it's a git thing. Not sure if it's local to my computer or not.

@AlaricWhitney AlaricWhitney requested review from mastercactapus, tony-tvu and Forfold and removed request for Forfold, mastercactapus and tony-tvu February 3, 2023 15:20
Forfold
Forfold previously approved these changes Feb 3, 2023
Copy link
Collaborator

@tony-tvu tony-tvu left a comment

Choose a reason for hiding this comment

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

I was able to functionally test this with a real phone call and change the voices. Hopefully the issue with build | fatal: No names found, cannot describe anything logs resolves itself when running on GoAlert's repo.

@AlaricWhitney AlaricWhitney merged commit 1dcdf4c into target:master Feb 23, 2023
@AlaricWhitney AlaricWhitney deleted the Adding-more-natural-sounding-voices-to-phoen-calls branch February 23, 2023 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjusting Phone Call Greetings to sound more natural Adding more natural sounding voices to phone calls
5 participants