Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 28th, 2013, 08:31 PM
MynE MynE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 35 MynE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 32 m 59 sec
Reputation Power: 1
Pyspeech capture some 'keywords'

Hi, I'm looking for a way to use pyspeech to capture some keywords. For example, when i said the words "Play music", the python will have to run the function to play music. However, I have to use the specific word 'play music' to run that function.

My question is, is there a way to capture only a word 'music'?, no matters what i'm saying but if the pyspeech can capture the word 'music' in my sentence, it has to run the music function. For example, if i said 'I want to listen my music' or 'Run music' something like this it has to play music anyway. If you have some idea or solution to solve this problem, please help

Here is my code:

Code:
import speech, pymedia

player = pymedia.Player()
player.start()

def playMusic():
   player.startPlayback('C:\MusicLibrary\song.mp3')

def command_callback(phrase, listener):
   if phrase == 'Music':     
          speech.say("Preparing music. . .")
          playMusic()

Command = speech.listenfor(['Music', 'Play music'],command_callback)

Reply With Quote
  #2  
Old March 1st, 2013, 01:29 AM
MynE MynE is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 35 MynE User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 32 m 59 sec
Reputation Power: 1
Looks like nobody knows about this stuff, anyway I've tried something and I hope some of you guys might have suggestions to me. Here's what I'm doing right now:

Code:
import speech, re, pymedia, os

player = pymedia.Player()
player.start()
ListSong = []
i = 0
for file in os.listdir('C:\MusicLibrary'):
   ListSong.append('C:\MusicLibrary'+'\\'+file)

response = []
response = speech.input(' ')
  
def STSong():
   global i 
   player.startPlayback(ListSong[i])

def command_callback(phrase, listener):
  if response != []:
    m = re.search("music", response)
    k = m.group(0)
    speech.say(k)
    phrase = k
    if phrase == "music":
      STSong()

AllCommand = speech.listenfor(('%s', response), command_callback)


As you can see, this code can capture the word 'music' from what I said, but there's two problems right now.

1. I've to repeat what I'm saying twice whenever I run the scripts because the first said is "response = speech.input(' ')" and the second one is in the command_callback() to make the music played.

2. After I gave the input to "response", it always keeps the value, is there a way to refresh and return the "response" back to the beginning? I mean after I gave the input to "response" and it played the music for me. I want this "response" to be cleared and go back to the top for waiting the new command. If somebody knows about this, please help me find out. I've been looking forward to see you guys' opinion

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Pyspeech capture some 'keywords'

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap