Python Forum
Strings with speech_recognition
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strings with speech_recognition
#1
Hi everyone,
I am trying to build my own google assistant but I got a problem I've already got the speech recognition but the problem is how do I separate a string. I need to separate it because I want more possibilities to say that something should be googled like:
  • search for something
  • show me something
  • what is something


Any ideas? Please let me know!
Reply
#2
#!/usr/bin/python3
dd = "A String with 4 words"
print(dd.split(" "))
Reply
#3
Well, problem is if it is "search for something something" it won't work....
Reply
#4
Then you should make an example for us.
Reply
#5
That's the problem I want it to be like the google assistant and there are more ways to tell that something should be found but I can't find a method to split the string in the right way but I just got an idea. Is there something in python like the "regular expressions" in Linux if so maybe it is possible to sort out using them.
Reply
#6
https://docs.python.org/3.7/library/re.html
Reply
#7
Thanks for the help everyone I got now my solution it is so simple that am ashamed not to think of it before:
search = "what is Hello"
search1 = "search for "
search2 = "show me "
search3 = "what is "

string_search = search.replace(search1, '')
string_search1 = string_search.replace(search2, '')
string_search2 = string_search1.replace(search3, '')
print(string_search2)
Reply
#8
Ok, glad to hear.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to understand strings and lists of strings Konstantin23 2 757 Aug-06-2023, 11:42 AM
Last Post: deanhystad
  Splitting strings in list of strings jesse68 3 1,757 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Am trying to use speech_recognition module but getting error NagaphaniKonaknchi 0 2,007 Jul-05-2020, 09:56 PM
Last Post: NagaphaniKonaknchi
  Finding multiple strings between the two same strings Slither 1 2,511 Jun-05-2019, 09:02 PM
Last Post: Yoriz
  lists, strings, and byte strings Skaperen 2 4,214 Mar-02-2018, 02:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020