OkanoShogo0903 / speech_recog

GoogleSpeechAPIを使ってマイク入力からストリームで音声認識させる
0 stars 0 forks source link

NUC8i7BEH #1

Open KITHappyRobot opened 5 years ago

KITHappyRobot commented 5 years ago

GoogleSpeechAPIが様々なエラーで動かなくなる件での備忘録

pyaudioのアップグレード

$ sudo apt-get remove python-pip
$ sudu apt-get install python-pip

プログラム起動から1分?ほど経つとgoogle.api_core.exceptions.ServiceUnavailable: 503 Connect Failed

録音時間が60秒を超えてくると音声ファイルが大きくなりすぎっていわれてClientが例外吐く仕様になっているので、おそらくそれ
害はなさそう

プログラム起動時にE0126 09:33:30.047345599 4922 http_proxy.cc:62] 'https' scheme not supported in proxy URIがでて

/usr/local/lib/python2.7/dist-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.がプログラム起動時に出る

-https://stackoverflow.com/questions/51283708/python-pip-package-requestsdependencywarning-when-installing-elastic-search-cura

$ sudo pip install --upgrade cryptography

以下の奇妙なエラー吐く。

Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

pipをアンインストールしてから最新版にしても同様のエラー. どうも、aptで入れたpipパッケージをpip自身でアップグレードしようとするとエラー吐くらしい そのため、以下を実行

$ python -m pip uninstall pip

そして不具合起こしていたパッケージを更新

$ sudo pip install --upgrade cryptography

ちなみにこのパッケージはどうも暗号化に関するものらしい

次なるエラー、AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

エラー全文は以下

athome@athome-NUC8i7BEH:~/python-docs-samples/speech/cloud-client$ python transcribe_streaming_mic.py 
Traceback (most recent call last):
  File "transcribe_streaming_mic.py", line 34, in <module>
    from google.cloud import speech
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech.py", line 19, in <module>
    from google.cloud.speech_v1 import SpeechClient
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech_v1/__init__.py", line 17, in <module>
    from google.cloud.speech_v1.gapic import speech_client
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech_v1/gapic/speech_client.py", line 22, in <module>
    import google.api_core.gapic_v1.client_info
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/gapic_v1/__init__.py", line 17, in <module>
    from google.api_core.gapic_v1 import method
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/gapic_v1/method.py", line 22, in <module>
    from google.api_core import grpc_helpers
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/grpc_helpers.py", line 27, in <module>
    import google.auth.transport.requests
  File "/usr/local/lib/python2.7/dist-packages/google/auth/transport/requests.py", line 23, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 95, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
    SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
KITHappyRobot commented 5 years ago

google.api_core.exceptions.ServiceUnavailable: 503 Connect Failed

有線で動作させてみる

エラーの内容変わらず.

ALSAがマイクを自動的に良さそうなものを選択してくれるようになっており、そこで変なものが選択されて認識できていない説

athome@athome-NUC8i7BEH:~/python-docs-samples/speech/cloud-client$ python transcribe.py resources/commercial_mono.wav 

公式のサンプルにあった、既存の音声ファイルを投げつけて認識結果を受け取るプログラムは、以下のようにうまく動作しなかった。 1分ほどなにも出力されない状態が続いたためCtrl-Cで落としたのが以下の出力結果

athome@athome-NUC8i7BEH:~/python-docs-samples/speech/cloud-client$ python transcribe.py resources/commercial_mono.wav 
E0126 11:29:01.377795406    5719 http_proxy.cc:62]           'https' scheme not supported in proxy URI
^CKeyboardInterrupt
Exception KeyboardInterrupt in 'grpc._cython.cygrpc._next' ignored
Traceback (most recent call last):
  File "transcribe.py", line 96, in <module>
    transcribe_file(args.path)
  File "transcribe.py", line 50, in transcribe_file
    response = client.recognize(config, audio)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech_v1/gapic/speech_client.py", line 239, in recognize
    request, retry=retry, timeout=timeout, metadata=metadata
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
    return wrapped_func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/retry.py", line 270, in retry_wrapped_func
    on_error=on_error,
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/retry.py", line 179, in retry_target
    return target()
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/timeout.py", line 214, in func_with_timeout
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py", line 549, in __call__
    wait_for_ready)
  File "/usr/local/lib/python2.7/dist-packages/grpc/_channel.py", line 538, in _blocking
    event = call.next_event()
  File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 310, in grpc._cython.cygrpc.SegregatedCall.next_event
  File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 151, in grpc._cython.cygrpc._next_call_event
  File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 152, in grpc._cython.cygrpc._next_call_event
  File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 308, in grpc._cython.cygrpc.SegregatedCall.next_event.on_success
  File "src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi", line 282, in grpc._cython.cygrpc._process_segregated_call_tag
KeyError: None

有線でエラーの内容が変わらず、マイクの問題でもない

関連するgooglのパッケージが古い説