SociallyIneptWeeb / LanguageLeapAI

Your Personal Multilingual AI Translator
MIT License
843 stars 171 forks source link

requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #93

Open pardon-hnu opened 1 year ago

pardon-hnu commented 1 year ago
image

I noticed that someone had asked this question before, so I used the latest code, but it still reported errors while running voice_translator.py

NikZip commented 1 year ago
INFO:werkzeug:127.0.0.1 - - [13/Apr/2023 21:58:27] "POST /asr?task=transcribe&language=en&output=json HTTP/1.1" 200 -
ERROR:__main__:Exception on /audio_query [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.9/dist-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/lib/python3.9/http/client.py", line 1285, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1331, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1280, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1040, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 980, in send
    self.connect()
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f636f0373d0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 440, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=50021): Max retries exceeded with url: /audio_query?text=%E4%BD%95%E3%81%8C%E7%A7%81%E3%81%9F%E3%81%A1%E3%81%AB%E5%8E%BB%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B%E3%81%AE%E3%81%8B%E8%A6%8B%E3%81%A6%E3%81%BF%E3%81%BE%E3%81%97%E3%82%87%E3%81%86%E3%80%82&speaker=15 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f636f0373d0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<ipython-input-17-dc03d861f2ed>", line 21, in audio_query
    r = requests.post(f'{VOICEVOX_URL}/audio_query?{params_encoded}')
  File "/usr/local/lib/python3.9/dist-packages/requests/api.py", line 117, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=50021): Max retries exceeded with url: /audio_query?text=%E4%BD%95%E3%81%8C%E7%A7%81%E3%81%9F%E3%81%A1%E3%81%AB%E5%8E%BB%E3%81%A3%E3%81%A6%E3%81%84%E3%82%8B%E3%81%AE%E3%81%8B%E8%A6%8B%E3%81%A6%E3%81%BF%E3%81%BE%E3%81%97%E3%82%87%E3%81%86%E3%80%82&speaker=15 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f636f0373d0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 2528, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1825, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.9/dist-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.9/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "<ipython-input-17-dc03d861f2ed>", line 25, in audio_query
    return Response(json.dumps({ 'message': 'Failed to request audio_query', 'json': r.json(), 'status': 'Server Error' }), mimetype='application/json', status=500)
UnboundLocalError: local variable 'r' referenced before assignment
INFO:werkzeug:127.0.0.1 - - [13/Apr/2023 21:58:30] "POST /audio_query?text=何が私たちに去っているのか見てみましょう。&speaker=15 HTTP/1.1" 500 -

Want to add some info about the error, this is log in run_whisper_n_voicevox.ipynb when trying to send file. I have firewall disabled

w2lf commented 1 year ago

I also have this issue with run_whisper_n_voicevox.ipynb.

I tried this it kind of worked.

WHISPER_BASE_URL=http://f026-34-30-34-129.ngrok-free.app
VOICEVOX_BASE_URL=http://f026-34-30-34-129.ngrok-free.app:50021

I also tried run_voicevox_colab and run_whisper_colab and have anther issue.

Exception in thread Thread-2:
Traceback (most recent call last):
  File "D:\SD\LanguageLeapAI\myenv\lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "E:\Programs\Anaconda3\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "E:\Programs\Anaconda3\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "E:\Programs\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\Programs\Anaconda3\lib\threading.py", line 980, in _bootstrap_inner
    self.run()
  File "E:\Programs\Anaconda3\lib\threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "D:\SD\LanguageLeapAI\myenv\lib\site-packages\keyboard\_generic.py", line 58, in process
    if self.pre_process_event(event):
  File "D:\SD\LanguageLeapAI\myenv\lib\site-packages\keyboard\__init__.py", line 213, in pre_process_event
    key_hook(event)
  File "D:\SD\LanguageLeapAI\myenv\lib\site-packages\keyboard\__init__.py", line 516, in <lambda>
    return hook_key(key, lambda e: e.event_type == KEY_DOWN or callback(e), suppress=suppress)
  File "D:\SD\LanguageLeapAI\src\voice_translator.py", line 80, in on_release_key
    speak(translated_speech, TARGET_LANGUAGE)
  File "D:\SD\LanguageLeapAI\src\modules\tts.py", line 9, in speak
    speak_jp(sentence)
  File "D:\SD\LanguageLeapAI\src\modules\voicevox.py", line 38, in speak_jp
    voicevox_query = r.json()
  File "D:\SD\LanguageLeapAI\myenv\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)