cmusphinx / g2p-seq2seq

G2P with Tensorflow
Other
670 stars 194 forks source link

TypeError in g2p-seq2seq --interactive #48

Closed DanielAsher closed 8 years ago

DanielAsher commented 8 years ago

Hi, thanks so much for this great project!

I have it running in --decode mode but run into this error when --interactivewhere I receive this message:

$ sudo g2p-seq2seq --interactive --model g2p-seq2seq-cmudict
Creating 2 layers of 512 units.
Reading model parameters from g2p-seq2seq-cmudict
> hello
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/bin/g2p-seq2seq", line 11, in <module>
    load_entry_point('g2p-seq2seq==5.0.0a0', 'console_scripts', 'g2p-seq2seq')()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/g2p_seq2seq-5.0.0a0-py3.5.egg/g2p_seq2seq/app.py", line 78, in main
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/g2p_seq2seq-5.0.0a0-py3.5.egg/g2p_seq2seq/g2p.py", line 308, in interactive
TypeError: decoding str is not supported

Sorry if this is a newbie error. Any help much appreciated :)

nshmyrev commented 8 years ago

This looks like you are using older version. Try with a fresh checkout, it was fixed with a4239f219b444aab236c6171487bdc45d3341038

DanielAsher commented 8 years ago

Hi Nickolay,

thanks for such a quick response. I re-cloned master (ec797a3) and checked I had a4239fs and reran sudo python3 setup.py install but got the same result. The error recurs so I assume my python installation is not quite right. Please comment or reopen if you feel you can help. Thanks again :)

Here is the console log (please forgive its length):

G2PAlignment $ git clone https://github.com/cmusphinx/g2p-seq2seq.git
Cloning into 'g2p-seq2seq'...
remote: Counting objects: 461, done.
remote: Total 461 (delta 0), reused 0 (delta 0), pack-reused 461
Receiving objects: 100% (461/461), 115.63 KiB | 0 bytes/s, done.
Resolving deltas: 100% (269/269), done.
Checking connectivity... done.
G2PAlignment $ cd g2p-seq2seq/
g2p-seq2seq $ ls
LICENSE.txt     g2p_seq2seq     tests
MANIFEST.in     googlecl-pylint.rc
README.md       setup.py
g2p-seq2seq $ sudo python3 setup.py install
Password:
running install
running bdist_egg
running egg_info
creating g2p_seq2seq.egg-info
writing entry points to g2p_seq2seq.egg-info/entry_points.txt
writing requirements to g2p_seq2seq.egg-info/requires.txt
writing dependency_links to g2p_seq2seq.egg-info/dependency_links.txt
writing top-level names to g2p_seq2seq.egg-info/top_level.txt
writing g2p_seq2seq.egg-info/PKG-INFO
writing manifest file 'g2p_seq2seq.egg-info/SOURCES.txt'
reading manifest file 'g2p_seq2seq.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'g2p_seq2seq.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-intel/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/g2p_seq2seq
copying g2p_seq2seq/__init__.py -> build/lib/g2p_seq2seq
copying g2p_seq2seq/app.py -> build/lib/g2p_seq2seq
copying g2p_seq2seq/data_utils.py -> build/lib/g2p_seq2seq
copying g2p_seq2seq/g2p.py -> build/lib/g2p_seq2seq
creating build/bdist.macosx-10.6-intel
creating build/bdist.macosx-10.6-intel/egg
creating build/bdist.macosx-10.6-intel/egg/g2p_seq2seq
copying build/lib/g2p_seq2seq/__init__.py -> build/bdist.macosx-10.6-intel/egg/g2p_seq2seq
copying build/lib/g2p_seq2seq/app.py -> build/bdist.macosx-10.6-intel/egg/g2p_seq2seq
copying build/lib/g2p_seq2seq/data_utils.py -> build/bdist.macosx-10.6-intel/egg/g2p_seq2seq
copying build/lib/g2p_seq2seq/g2p.py -> build/bdist.macosx-10.6-intel/egg/g2p_seq2seq
byte-compiling build/bdist.macosx-10.6-intel/egg/g2p_seq2seq/__init__.py to __init__.cpython-35.pyc
byte-compiling build/bdist.macosx-10.6-intel/egg/g2p_seq2seq/app.py to app.cpython-35.pyc
byte-compiling build/bdist.macosx-10.6-intel/egg/g2p_seq2seq/data_utils.py to data_utils.cpython-35.pyc
byte-compiling build/bdist.macosx-10.6-intel/egg/g2p_seq2seq/g2p.py to g2p.cpython-35.pyc
creating build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying g2p_seq2seq.egg-info/PKG-INFO -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying g2p_seq2seq.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying g2p_seq2seq.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying g2p_seq2seq.egg-info/entry_points.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying g2p_seq2seq.egg-info/requires.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying g2p_seq2seq.egg-info/top_level.txt -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/g2p_seq2seq-5.0.0a0-py3.5.egg' and adding 'build/bdist.macosx-10.6-intel/egg' to it
removing 'build/bdist.macosx-10.6-intel/egg' (and everything under it)
Processing g2p_seq2seq-5.0.0a0-py3.5.egg
Removing /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/g2p_seq2seq-5.0.0a0-py3.5.egg
Copying g2p_seq2seq-5.0.0a0-py3.5.egg to /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
g2p-seq2seq 5.0.0a0 is already the active version in easy-install.pth
Installing g2p-seq2seq script to /Library/Frameworks/Python.framework/Versions/3.5/bin

Installed /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/g2p_seq2seq-5.0.0a0-py3.5.egg
Processing dependencies for g2p-seq2seq==5.0.0a0
Searching for tensorflow==0.9.0
Best match: tensorflow 0.9.0
Adding tensorflow 0.9.0 to easy-install.pth file
Installing tensorboard script to /Library/Frameworks/Python.framework/Versions/3.5/bin

Using /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Searching for wheel==0.29.0
Best match: wheel 0.29.0
Adding wheel 0.29.0 to easy-install.pth file
Installing wheel script to /Library/Frameworks/Python.framework/Versions/3.5/bin

Using /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Searching for numpy==1.11.1
Best match: numpy 1.11.1
Adding numpy 1.11.1 to easy-install.pth file

Using /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Searching for six==1.10.0
Best match: six 1.10.0
Processing six-1.10.0-py3.5.egg
six 1.10.0 is already the active version in easy-install.pth

Using /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/six-1.10.0-py3.5.egg
Searching for protobuf==3.0.0b2
Best match: protobuf 3.0.0b2
Adding protobuf 3.0.0b2 to easy-install.pth file

Using /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Searching for setuptools==26.1.1
Best match: setuptools 26.1.1
Adding setuptools 26.1.1 to easy-install.pth file
Installing easy_install-3.5 script to /Library/Frameworks/Python.framework/Versions/3.5/bin
Installing easy_install script to /Library/Frameworks/Python.framework/Versions/3.5/bin

Using /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Finished processing dependencies for g2p-seq2seq==5.0.0a0
g2p-seq2seq $ wget -O g2p-seq2seq-cmudict.tar.gz https://sourceforge.net/projects/cmusphinx/files/G2P%20Models/g2p-seq2seq-cmudict.tar.gz/download 
--2016-09-09 08:52:54--  https://sourceforge.net/projects/cmusphinx/files/G2P%20Models/g2p-seq2seq-cmudict.tar.gz/download
Resolving sourceforge.net... 216.34.181.60
Connecting to sourceforge.net|216.34.181.60|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://downloads.sourceforge.net/project/cmusphinx/G2P%20Models/g2p-seq2seq-cmudict.tar.gz?r=&ts=1473407575&use_mirror=netcologne [following]
--2016-09-09 08:52:54--  http://downloads.sourceforge.net/project/cmusphinx/G2P%20Models/g2p-seq2seq-cmudict.tar.gz?r=&ts=1473407575&use_mirror=netcologne
Resolving downloads.sourceforge.net... 216.34.181.59
Connecting to downloads.sourceforge.net|216.34.181.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://netcologne.dl.sourceforge.net/project/cmusphinx/G2P%20Models/g2p-seq2seq-cmudict.tar.gz [following]
--2016-09-09 08:52:55--  http://netcologne.dl.sourceforge.net/project/cmusphinx/G2P%20Models/g2p-seq2seq-cmudict.tar.gz
Resolving netcologne.dl.sourceforge.net... 78.35.24.46, 2001:4dd0:1234:6::5f
Connecting to netcologne.dl.sourceforge.net|78.35.24.46|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 28465508 (27M) [application/x-gzip]
Saving to: 'g2p-seq2seq-cmudict.tar.gz'

g2p-seq2seq-cmudict. 100%[=======================>]  27.15M  5.46MB/s   in 5.9s   

2016-09-09 08:53:01 (4.60 MB/s) - 'g2p-seq2seq-cmudict.tar.gz' saved [28465508/28465508]

g2p-seq2seq $ tar xf g2p-seq2seq-cmudict.tar.gz
g2p-seq2seq $ g2p-seq2seq --interactive --model g2p-seq2seq-cmudict
Creating 2 layers of 512 units.
Reading model parameters from g2p-seq2seq-cmudict
> hello
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/bin/g2p-seq2seq", line 11, in <module>
    load_entry_point('g2p-seq2seq==5.0.0a0', 'console_scripts', 'g2p-seq2seq')()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/g2p_seq2seq-5.0.0a0-py3.5.egg/g2p_seq2seq/app.py", line 78, in main
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/g2p_seq2seq-5.0.0a0-py3.5.egg/g2p_seq2seq/g2p.py", line 308, in interactive
TypeError: decoding str is not supported

g2p-seq2seq $ git rev-parse HEAD
ec797a3369dd646142c55f147f6adfbdacb818bd
g2p-seq2seq $ git log
commit ec797a3369dd646142c55f147f6adfbdacb818bd
Author: Nickolay Shmyrev <nshmyrev@gmail.com>
Date:   Thu Aug 25 15:58:06 2016 +0200

    Small pylint fix

commit a4239f219b444aab236c6171487bdc45d3341038
Author: Nickolay Shmyrev <nshmyrev@gmail.com>
Date:   Thu Aug 25 15:47:01 2016 +0200

    Use six library for Python3 compatibility

    See for details https://github.com/cmusphinx/g2p-seq2seq/pull/47
nshmyrev commented 8 years ago

Thanks for testing, what exactly is written in the line 308 here:

File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/g2p_seq2seq-5.0.0a0-py3.5.egg/g2p_seq2seq/g2p.py", line 308, in interactive

DanielAsher commented 8 years ago

Thanks for reopening this. Line 308:

word = text_type(input("> "), encoding="utf-8", errors="replace")

in the context:

  def interactive(self):
    """Decode word from standard input.
    """
    while True:
      try:
        word = text_type(input("> "), encoding="utf-8", errors="replace")
      except EOFError:
        break
      if not word:
        break
      print(self.decode_word(word))
nshmyrev commented 8 years ago

Ok, what does this command print to you:

python -c "import six; print six.__version__"

DanielAsher commented 8 years ago
site-packages $ python -c "import six; print six.__version__"
1.10.0
nshmyrev commented 8 years ago

Ok, I've just pushed fe5ef7d3e6d286c412291c1faa35d51c2b5d8d65, please try it out

DanielAsher commented 8 years ago

I can verify this works. Thanks so much!