0

Hello i am using pyspeech and googlemaps in python to get direction and i'm trying to make pyspeech say the directions out loud thing is that is say like greater than, less than and b for the "< b >" in the code is there a way to ignore these brackets and just say the rest or the directions?

Code:

from googlemaps import GoogleMaps
import speech
api_key = (my key)
gmaps = GoogleMaps(api_key)
place1 = raw_input("Your address: ")
place = raw_input("Destination: ")
start = place1
end = place
dirs = gmaps.directions(start, end)
time = dirs['Directions']['Duration']['seconds']
dist = dirs['Directions']['Distance']['meters']
route = dirs['Directions']['Routes'][0]
for step in route['Steps']:
    print step['descriptionHtml']
    speech.say(step['descriptionHtml'])
user2458048
  • 116
  • 1
  • 4
  • 13

1 Answers1

1

Since each of the steps are just strings, all you need to do is use:

step['descriptionHtml'].replace("<b>", "").replace("</b>", "")

to remove the HTML tags.

Another option to consider is to just strip all the HTML from the text, but that might be overkill if the only tags you encounter are <b> and </b>.

Community
  • 1
  • 1
Chris Laplante
  • 29,338
  • 17
  • 103
  • 134