Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41354 > unrolled thread
| Started by | Nic <nicktwain@gmail.com> |
|---|---|
| First post | 2013-03-17 07:04 -0700 |
| Last post | 2013-03-17 14:48 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
How to make a Python script to audio read a text file on phone ? Nic <nicktwain@gmail.com> - 2013-03-17 07:04 -0700
Re: How to make a Python script to audio read a text file on phone ? dey.sumit.kr@gmail.com - 2013-03-17 14:48 -0700
| From | Nic <nicktwain@gmail.com> |
|---|---|
| Date | 2013-03-17 07:04 -0700 |
| Subject | How to make a Python script to audio read a text file on phone ? |
| Message-ID | <287a6f55-279f-4ddf-9020-c61bca585262@googlegroups.com> |
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! [Quote] # 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]
[toc] | [next] | [standalone]
| From | dey.sumit.kr@gmail.com |
|---|---|
| Date | 2013-03-17 14:48 -0700 |
| Message-ID | <d0a4d7df-d809-4098-861a-dd32f283c9b1@googlegroups.com> |
| In reply to | #41354 |
On Sunday, March 17, 2013 7:34:18 PM UTC+5:30, Nic wrote:
> 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!
>
>
>
>
>
> [Quote]
>
>
>
> # 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()
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web