how to play mp3 file on voice command

Hi  Inmoov Team,

 

pls. let us know how to run any mp3 file in inmoov script.

thanks and regards.

 

sunil

Mats's picture

AudioFile service

You use the AudioFile service like this:

AudioPlayer = Runtime.start("AudioPlayer","AudioFile")
AudioPlayer.playFile(RuningFolder+'/system/sounds/startupsound.mp3', False)
 
Replace RuningFolder+'/system/sounds/startupsound.mp3 with the path to your soundfile
 
 
sunilskar's picture

audio file.

Mr. Mats,uThnaks for giving responce for my post.

But still we couldn't start it with voice command of  "play  music " or play some music.

below are the updated file of audio.py

# ##############################################################################
#                 AUDIOFILE SERVICE
# ##############################################################################
# http://myrobotlab.org/service/audiofile

# ##############################################################################
# MRL SERVICE CALL
# ##############################################################################

#startup sound
AudioPlayer = Runtime.createAndStart("AudioPlayer", "AudioFile")

def onAudioStart(data):
  if AudioSignalProcessing and isHeadActivated:
    print "onaudiostart"
    try:
      head.attach()
      head.jaw.moveTo(180)
      left.enablePin(AnalogPinFromSoundCard,HowManyPollsBySecond)
    except:
      print "onAudioStart error"
      pass

def onAudioEnd(data):
  if AudioSignalProcessing and isHeadActivated:
    try:
      left.disablePin(AnalogPinFromSoundCard)
      #head.jaw.detach()
    except:
      print "onAudioEnd error"
      pass
      
def AudioPlay(file):
  AudioPlayer.playFile(file,False)
      

python.subscribe(AudioPlayer.getName(),"publishAudioStart")
python.subscribe(AudioPlayer.getName(),"publishAudioEnd")
#if StartupSound:AudioPlayer.playFile(RuningFolder+'/system/sounds/startupsound.mp3', False)
if StartupSound:AudioPlayer.playFile(RuningFolder+'C:\Users\sunil\Music\HEROPANTI\whistle-baja-(Muskurahat.Com).mp3', False)
sleep(2)    
 

 

thanks

Mats's picture

AIML

OK

If you want to use voice commands like "play song" you should define that in InMoovs "brain".

InMoov "brain" is the ProgramAB service, and it uses a lot of different *.aiml files to define what InMoov will do in response to different commands. 

Here is the link to the ProgramAB service page.

http://myrobotlab.org/service/ProgramAB

Here is one thread that discusses different ways to define the aiml files. 

http://myrobotlab.org/content/programab-aiml-and-mrl-support-oob-tags

Install the InMoov service and the ProgramAB service, and you will find a lot of examples in

<MRL home>/InMoov/chatbot/bots/<language>/aiml

You can also search this site for ProgramAB or AIML.

The AIML to execute a method in a service looks like this:

<category>

<pattern>PLAY SONG</pattern>

    <template>Playing a song
      <oob>
        <mrl>
        <service>AudioPlayer</service>
        <method>play</method>
         <param>C:\MRL2212\InMoov\system\sounds\Notifications\alive.mp3</param>
       </mrl>
      </oob></template>
  </category>

To execute a function in a python script:

        <oob>

          <mrl>
            <service>python</service>
            <method>exec</method>
            <param>AudioPlay(C:\MRL2212\InMoov\system\sounds\Notifications\alive.mp3)</param>
          </mrl>
        </oob>
 
Using hardcoded paths like I do in the example is not really good. It's just to give an example.
 
I would define a function in python that contains the path to where the sound files exists, and just select the song to be played in the aiml.
 
I hope this helps you to get stated with playing with InMoovs brain.
 
sunilskar's picture

Thanks a lot sir, i will try

Thanks a lot sir,

i will try this and get back to you .

 

sunilskar's picture

Hi Mats, I tried to load play

Hi Mats,

I tried to load play song command in python . it run and play specific song but it will not stop or go to next song,

i think we should write all command like play , next, return,pause and stop for this category .

if possible can you give a flow chart for the same.

thanks in advance.

sunil