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

Limit interpret-as=address to numbers in road names #552

Merged
merged 4 commits into from Aug 29, 2017
Merged

Conversation

bsudekum
Copy link
Contributor

Came across a case where polly speaks N Street NW as North Street NW. The if-first-word-in-ref code we had in place for refs should also be applied to .wayName, .destination, .rotaryName.

/cc @ericrwolfe @frederoni @1ec5

@1ec5
Copy link
Contributor

1ec5 commented Aug 28, 2017

What if the street is named North S Street, East W Avenue or Northwest N Street?

This is symptomatic of a broader issue we have with Polly, which is that it keeps trying to expand abbreviations even though abbreviations are already expanded in OpenStreetMap. Can you look into whether there’s a way to specify in SSML that abbreviation expansion should be disabled?

@1ec5 1ec5 changed the title Speak name as characters when caps Limit interpret-as=address to numbers in road names Aug 28, 2017
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

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

We can probably roll back #418, since it was address that was causing parentheses to be read aloud.

/ref #286 (comment)

@@ -52,4 +52,8 @@ extension String {
var isUppercased: Bool {
return self == uppercased() && self != lowercased()
}

var isInt: Bool {
return Int(self) != nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will miss route numbers like NY 120A, in which 120A should be wrapped in interpret-as="address" in order to say “one-twenty a” instead of “one hundred twenty a”. How about wrapping a word in address if it contains a digit?

let refComponents = value.addingXMLEscapes.components(separatedBy: .whitespaces)
guard var firstRefComponent = refComponents.first else { return value.asSSMLAddress }
case .wayName, .destination, .rotaryName, .code:
let stringComponents = value.addingXMLEscapes.components(separatedBy: .whitespaces)
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, this will miss any codes like A-35. OSM tagging conventions call for a space, as in I 35, but I do see some other regions using hyphens. We could harden this code by enumerating the string with String.enumerateSubstrings(in:options:_:) and byWord, or with String.replacingOccurrences(of:with:options:range:) and regularExpression.

@bsudekum
Copy link
Contributor Author

bsudekum commented Aug 29, 2017

@1ec5 current code produces something like given the names above:

<speak>
  <prosody volume='x-loud' rate='1.08'>
    Head east on NY <say-as interpret-as="address">120A</say-as> <say-as interpret-as="address">A-35</say-as>, then in 3 quarters of a mile , Turn right onto NY <say-as interpret-as="address">120A</say-as> <say-as interpret-as="address">A-35</say-as>
  </prosody>
</speak>

@bsudekum
Copy link
Contributor Author

link to mp3: https://cloudup.com/c_X5YsKdCFh

@ericrwolfe ericrwolfe modified the milestone: v0.7.0-5 Aug 29, 2017
@@ -52,4 +52,8 @@ extension String {
var isUppercased: Bool {
return self == uppercased() && self != lowercased()
}

var containsInt: Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: containsDecimalDigit would be more accurate.

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.

None yet

3 participants