Text to speech:
#Copyright (c) 2008 Pankaj Nathani
#Using text-to-speech
#You can use the text-to-speech engine of the phone to make is read text aloud
import audio
audio.say("This is an example")
Playing sound:
#Copyright (c) 2008 Pankaj Nathani
#Playing a sound
import audio, appuifw
#Define the function for stopping the playback
def stop():
global s
s.stop()
s.close()
appuifw.app.exit_key_handler=stop
#Open the sound file
s=audio.Sound.open("C:\\music.mp3")
#Play it
s.play()
#This plays the file once; to play it indefinitely use s.play(KMdaRepeatForever)
Recording sound:
#Copyright (c) 2008 Pankaj Nathani
#Recording sound
import audio, appuifw
def stop():
global s
s.stop()
s.close()
appuifw.app.exit_key_handler=stop
#Open a new file for recording
s=audio.Sound.open("C:\\recorded.amr")
#Start recording
s.record()
Setting volume:
#Copyright (c) 2008 Pankaj Nathani
#Setting the volume and position and getting duration
import audio, appuifw
def stop():
global s
s.stop()
s.close()
s=audio.Sound.open("C:\\s.mp3")
#Show the current volume and the maximum volume
appuifw.note(u"Current volume %d" % s.current_volume())
appuifw.note(u"Max volume %d" % s.max_volume())
#Ask the user for new volume
v=appuifw.query(u"New volume", "number")
s.set_volume(v)
appuifw.note(u"The duration of this song is %d seconds" % int(s.duration()/1000000))
s.set_position(3) #3 seconds
appuifw.note(u"%d seconds have been played" % int(s.current_position())) #In this case 3.4 seconds