הנכם מוזמנים לתרום להוספת מילים לקובץ המילון שהתחלתי
אני אשתדל לעדכן את הקוד שייקרא קטעים יותר גדולים ועם יותר שורות
לבינתיים לילה טוב כתבתי מספיק להיום .
למי שרוצה להנות מהקראת טקסט בעברית
יש לשמור את קטעי הקוד בשמות קבצים כמו בכותרות
ולהריץ python hebrew_read.py
הקוד פתוח תחת GPL לכל המעוניין.
קוד: |
##############################################
#this is hebrew_read.py file
##############################################
import os
debug="true"
def load_dictionary():
f=open("hebrew_fonetic.lang","r")
data=f.readlines()
data = [x for x in data if "#" not in x]
print data
dic={}
for x in data:
y = x.split("=")
y[0] = y[0].replace('"','')
y[0] = y[0].replace(" ","")
y[1] =y[1].replace("\n","")
y[1] = y[1].lstrip().rstrip()
y[1] = y[1].replace('"','')
dic[y[0]]=y[1]
if debug:
print "dictionary:\n"
for x in dic.keys():
print x," :",repr(x)," :",dic[x]
print "\n"
return dic
def load_stream():
t=open("my_stream.txt","r")
s=t.readlines()
s=[x for x in s if "#" not in x]
print s
n=[]
for x in s:
x=x.replace(",","")
for y in x.split(" "):
n.append(y)
if debug:
print "\n","the stream is:"
for x in n:
print x," ",repr(x)
return n
def render_stream_out(dic,n):
p=r"spd-say '"
for x in n:
if x in dic.keys():
p = p + dic[x]+" "
else:
pass
p = p +"'"
return p
my_dic = load_dictionary()
txt_stream = load_stream()
strout = render_stream_out(my_dic,txt_stream)
os.system(strout)
##############################################
#end of hebrew_read.py file
##############################################
|
קוד: |
##############################################
#this is my_stream.txt file#
##############################################
יניב הראל מנהל את קבוצת פתרונות, הסייבר בתחום
##############################################
#end of my_stream file#
##############################################
|
קוד: |
##############################################
#this is hebrew_fonetic.lang file#
##############################################
"יניב" = "ya niv"
"הראל" = "har el"
"מנהל" = "me na hel"
"קבוצת" = "kvu zat"
"פתרונות" = "pit ro not"
"בתחום" = "hat hum"
"הסייבר" = "ha sai ber"
"את" = "et"
##############################################
#end of hebrew_fonetic.lang file#
##############################################
|