User:Manetta/scripts/python-translate-to-computer-phonemes: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
Line 1: Line 1:
= translating text into computer phonemes =
= translating text into phonemes used by Sphinx =
 
[https://en.wikipedia.org/wiki/CMU_Pronouncing_Dictionary article on Wikipedia about the cmu07a.dic]


using the CMU dictionary file from the software package [http://cmusphinx.sourceforge.net/ Sphinx] (cmu07a.dic)<br>
using the CMU dictionary file from the software package [http://cmusphinx.sourceforge.net/ Sphinx] (cmu07a.dic)<br>

Revision as of 00:07, 27 March 2015

translating text into phonemes used by Sphinx

article on Wikipedia about the cmu07a.dic

using the CMU dictionary file from the software package Sphinx (cmu07a.dic)
for download here: http://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/
cmu07a.dic looks like:

abso	AE B S OW
absolom	AE B S AH L AH M
absolut	AE B S AH L UW T
absolut's	AE B S AH L UW T S
absolute	AE B S AH L UW T
absolutely	AE B S AH L UW T L IY
absoluteness	AE B S AH L UW T N AH S
absolutes	AE B S AH L UW T S
absolution	AE B S AH L UW SH AH N
absolutism	AE B S AH L UW T IH Z AH M
absolutist	AE B S IH L UW T IH S T
absolve	AH B Z AA L V


import re
import os

with open('output.txt', 'w') as txt:

	x = open('input.txt', 'r')
	searchlines = x.readlines()
	x.close()
	print searchlines
	search = searchlines[0].split(" ")
	print search[0]

	for i, searchitem in enumerate(search):
		print searchitem
		dic = open('cmu07a.dic', 'r')
		for line in dic:
			if re.match(searchitem, line): 
				print line
				break		
				txt.write(line), "\n"
		dic.close()


call	K AO L
me	M IY
echo	EH K OW
my	M AY
wife	W AY F
is	IH Z
echo	EH K OW
my	M AY
brother	B R AH DH ER
is	IH Z
echo	EH K OW
echo	EH K OW
is	IH Z
my	M AY
mom	M AA M
my	M AY
boss	B AA S
name	N EY M
is	IH Z
echo	EH K OW
my	M AY
dad	D AE D
is	IH Z
echo	EH K OW


Mb-echo-semantic-simulations-01-page005.png