How to make a Python script to audio read a text file on phone ?

N

Nic

I've installed Python on my Nokia E71 (Symbian S60 3rd FP1) and found a script example which can read out text, see example below.
I want to make the script to asks me for a text file instead and then reads out the content. I guess it works with a .txt file, dont know if other formats work. Regards!


# Copyright (c) 2006 Jurgen Scheible
# This script performs a query with a single-field dialog (text input field)
# and lets the phone speak out the text (text to speech) that the users have typed in
# NOTE: this script runs only with Python S60 version 3.1.14 or above
# NOTE: this script doesn't work on all S60 phones neccessarily. Check your phone model if it has text to speech capability at all

import appuifw
import audio

text = appuifw.query(u"Type a word:", "text")
audio.say(text)

[End Quote]
 
D

dey.sumit.kr

I've installed Python on my Nokia E71 (Symbian S60 3rd FP1) and found a script example which can read out text, see example below.

I want to make the script to asks me for a text file instead and then reads out the content. I guess it works with a .txt file, dont know if other formats work. Regards!





# Copyright (c) 2006 Jurgen Scheible

# This script performs a query with a single-field dialog (text input field)

# and lets the phone speak out the text (text to speech) that the users have typed in

# NOTE: this script runs only with Python S60 version 3.1.14 or above

# NOTE: this script doesn't work on all S60 phones neccessarily. Check your phone model if it has text to speech capability at all



import appuifw

import audio



text = appuifw.query(u"Type a word:", "text")

audio.say(text)



[End Quote]

Here is a code that works fine for PC. Hope it'll work for you..

def op():
global TXT, L
filepath = tkFileDialog.askopenfilename(filetypes=[("Text Files","*.txt")])
if(len(filepath) == 0):
return 0
F = open(filepath,'r')
TXT = F.read()
F.close()
filename = filepath.split("/")
filename = filename[-1]
L.config(text=filename+": "+filepath)

def play():
global TXT
audio.say(TXT) ##Used as mentioned
print "said"


from Tkinter import *
import Tkconstants, tkFileDialog

import audio ##used as mentioned

TXT = ""

root = Tk()
root.title("Read that Out!!")

L = Label(text="No File Selected!",width="35",fg="black",bg="white")
L.grid(row=1,column=1)

F = Frame(root)
F.grid(row=2,column=1)

Button(F,text="Open File",command=op).grid(row=1,column=1)
Button(F,text="Read File",command=play).grid(row=1,column=2)

root.mainloop()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top