FoloToy / folotoy-server-self-hosting

Config files for self-hosting the FoloToy Server. Documents: https://docs.folotoy.com
https://tool.folotoy.com
GNU General Public License v3.0
446 stars 82 forks source link

仙人掌连接自建 mqtt server, 发送语音后报错。 #139

Open bluezd opened 5 months ago

bluezd commented 5 months ago
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,212 - DEBUG - STT type: openai-whisper
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,216 - DEBUG - load_ssl_context verify=True cert=None trust_env=True http2=False
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,225 - DEBUG - load_verify_locations cafile='/usr/local/lib/python3.11/site-packages/certifi/cacert.pem'
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,282 - DEBUG - Request options: {'method': 'post', 'url': '/audio/transcriptions', 'headers': {'Content-Type': 'multipart/form-data'}, 'files': [('file', SerializationIterator(index=0, iterator=<_io.BufferedReader name='/audio/recording-63d2f9f31b43468ab175078b7032b9be.wav'>))], 'json_data': {'model': 'whisper', 'language': 'zh', 'prompt': "ok. let's begin.", 'response_format': 'json'}}
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,302 - DEBUG - connect_tcp.started host='openai-jude.openai.azure.com' port=443 local_address=None timeout=5.0 socket_options=None
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,524 - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f82b7b150>
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,524 - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0x7f82b012e0> server_hostname='openai-jude.openai.azure.com' timeout=5.0
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,526 - DEBUG - start_tls.failed exception=ConnectError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1006)'))
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,527 - DEBUG - Encountered Exception
folotoy-server-self-hosting-folotoy-1  | Traceback (most recent call last):
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
folotoy-server-self-hosting-folotoy-1  |     yield
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 233, in handle_request
folotoy-server-self-hosting-folotoy-1  |     resp = self._pool.handle_request(req)
folotoy-server-self-hosting-folotoy-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
folotoy-server-self-hosting-folotoy-1  |     raise exc from None
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
folotoy-server-self-hosting-folotoy-1  |     response = connection.handle_request(
folotoy-server-self-hosting-folotoy-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
folotoy-server-self-hosting-folotoy-1  |     raise exc
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
folotoy-server-self-hosting-folotoy-1  |     stream = self._connect(request)
folotoy-server-self-hosting-folotoy-1  |              ^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 154, in _connect
folotoy-server-self-hosting-folotoy-1  |     stream = stream.start_tls(**kwargs)
folotoy-server-self-hosting-folotoy-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/sync.py", line 152, in start_tls
folotoy-server-self-hosting-folotoy-1  |     with map_exceptions(exc_map):
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
folotoy-server-self-hosting-folotoy-1  |     self.gen.throw(typ, value, traceback)
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
folotoy-server-self-hosting-folotoy-1  |     raise to_exc(exc) from exc
folotoy-server-self-hosting-folotoy-1  | httpcore.ConnectError: EOF occurred in violation of protocol (_ssl.c:1006)
folotoy-server-self-hosting-folotoy-1  |
folotoy-server-self-hosting-folotoy-1  | The above exception was the direct cause of the following exception:
folotoy-server-self-hosting-folotoy-1  |
folotoy-server-self-hosting-folotoy-1  | Traceback (most recent call last):
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 926, in _request
folotoy-server-self-hosting-folotoy-1  |     response = self._client.send(
folotoy-server-self-hosting-folotoy-1  |                ^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 914, in send
folotoy-server-self-hosting-folotoy-1  |     response = self._send_handling_auth(
folotoy-server-self-hosting-folotoy-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 942, in _send_handling_auth
folotoy-server-self-hosting-folotoy-1  |     response = self._send_handling_redirects(
folotoy-server-self-hosting-folotoy-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 979, in _send_handling_redirects
folotoy-server-self-hosting-folotoy-1  |     response = self._send_single_request(request)
folotoy-server-self-hosting-folotoy-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1015, in _send_single_request
folotoy-server-self-hosting-folotoy-1  |     response = transport.handle_request(request)
folotoy-server-self-hosting-folotoy-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 232, in handle_request
folotoy-server-self-hosting-folotoy-1  |     with map_httpcore_exceptions():
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
folotoy-server-self-hosting-folotoy-1  |     self.gen.throw(typ, value, traceback)
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
folotoy-server-self-hosting-folotoy-1  |     raise mapped_exc(message) from exc
folotoy-server-self-hosting-folotoy-1  | httpx.ConnectError: EOF occurred in violation of protocol (_ssl.c:1006)
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,534 - DEBUG - 1 retry left
folotoy-server-self-hosting-folotoy-1  | 2024-03-26 20:07:38,535 - INFO - Retrying request to /audio/transcriptions in 0.755807 seconds
lewangdev commented 5 months ago

hi,请把docker-compose.yml和roles .json 去掉 key 之后也发出来。

另外 azure 的 whisper 需要单独申请和部署的,可以现在azure网站上测试一下是否可以使用

bluezd commented 5 months ago

hi,请把docker-compose.yml和roles .json 去掉 key 之后也发出来。

docker-compose.yml

version: '3'
volumes:
  emqx-etc:
  emqx-data:
  emqx-log:
services:
  emqx:
    image: emqx/emqx:latest
    restart: always
    ports:
      - "1883:1883/tcp"
      - "18083:18083/tcp"
      - "8083:8083/tcp"
    volumes:
      - emqx-etc:/opt/emqx/etc
      - emqx-data:/opt/emqx/data
      - emqx-log:/opt/emqx/log
    environment:
      EMQX_NODE_NAME: emqx@node1.emqx.io
  nginx:
    image: nginx:latest
    restart: always
    ports:
      - "8082:80/tcp"
    volumes:
      - ./audio:/usr/share/nginx/html
  folotoy:
    image: lewangdev/folotoy-server:latest
    restart: always
    ports:
      - "8085:8085/udp"
    volumes:
      - ./audio:/audio
      - ./config:/config
    environment:
      TZ: Asia/Shanghai

      LOG_LEVEL: DEBUG

      ROLES_FILE_PATH: /config/roles.json

      # Default STT(Sound To Text) type
      # Options: [openai-whisper, azure-whisper, azure-stt, dify-stt, aliyun-asr]
      STT_TYPE: openai-whisper

      # OpenAI Whisper
      OPENAI_WHISPER_API_BASE: https://openai-XXX.openai.azure.com
      OPENAI_WHISPER_KEY: XXX
      OPENAI_WHISPER_MODEL: whisper

      # Azure Whisper
      AZURE_WHISPER_API_BASE: https://openai-XXX.openai.azure.com
      AZURE_WHISPER_KEY: XXX
      AZURE_WHISPER_DEPLOYMENT_NAME: whisper
      AZURE_WHISPER_API_VERSION: 2023-09-01-preview

      # Azure STT
      AZURE_STT_KEY: 3eba91b6143f4d3eeeeeeeeeeeeeeeeeeeeeeeee
      AZURE_STT_SERVICE_REGION: eastasia

      # Dify STT
      DIFY_STT_API_BASE: https://api.dify.ai/v1
      DIFY_STT_KEY: app-xxxxxxxxxxxxxxxxxxxxx

      # Aliyun ASR
      ALIYUN_ASR_ACCESS_KEY_ID: LTxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_ASR_ACCESS_KEY_SECRET: 3zWkHVxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_ASR_APP_KEY: Ltamxxxxxxxxxxxxxxxxxxxxx

      # Default LLM(Large Language Model) type
      # Options: [openai, azure-openai, gemini, dify, qianfan]
      LLM_TYPE: openai

      # OpenAI
      OPENAI_OPENAI_API_BASE: https://openai-XXX.openai.azure.com/
      OPENAI_OPENAI_MODEL: XXX
      OPENAI_OPENAI_KEY: XXX

      #Azure OpenAI
      AZURE_OPENAI_KEY: ef0f2781b5a24b15baaaaaaaaaaaaaaaaaaaaaaa
      AZURE_OPENAI_ENDPOINT: https://xxxxx.openai.azure.com/
      AZURE_OPENAI_API_VERSION: "2023-05-15"
      #AZURE_OPENAI_MODEL: gpt-35-turbo

      #DIFY
      DIFY_API_BASE: https://api.dify.ai/v1
      DIFY_KEY: app-5YGbxxxxxxxxxxxxxxxxxxxxx

      #Xiaodu API
      XIAODU_CLIENT_ID: xxxxxxxxxxxxxxxxxx
      XIAODU_SECRET: xxxxxxxxxxxxxxxxxxxxx

      # GEMINI
      GEMINI_KEY: AIzaSyxxxxxxxxxxxxxxxxxxk

      # Qianfan
      QIANFAN_CLIENT_ID: 13rBTgxxxxxxxxxxxxxxxxxx
      QIANFAN_SECRET: zYxtMIQLexxxxxxxxxxxxxxxxxx

      # If your elevenlabs is a free account, keep 2 here
      VOICE_EXECUTOR_MAX_WORKERS: 2

      # Default TTS(Text to Sound) type
      # Options: [openai-tts, azure-tts, elevenlabs, edge-tts, aliyun-tts]
      # edge-tts is Free but slow
      TTS_TYPE: edge-tts

      # Azure TTS
      AZURE_TTS_KEY: 3eba91b6143f4d399edeeeeeeeeeeeeeeeeeeeee
      AZURE_TTS_SERVICE_REGION: eastasia

      # elevenlabs
      ELEVENLABS_TTS_KEY: a920b73991e68d5c9c9aaaaaaaaaaaaaaaa
      ELEVENLABS_TTS_MODEL: eleven_multilingual_v2

      # OpenAI TTS
      OPENAI_TTS_KEY: sk-16XnP3HLHWho21oO2m0AAAAAAAAAAAAAAAAAAAAAA
      OPENAI_TTS_MODEL: tts-1

      # Aliyun TTS
      ALIYUN_TTS_ACCESS_KEY_ID: LTAI5t91NSxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_TTS_ACCESS_KEY_SECRET: 3zWkHVxxxxxxxxxxxxxxxxxxxxx
      ALIYUN_TTS_APP_KEY: Ltamxxxxxxxxxxxxx

      AUDIO_DOWNLOAD_URL: http://192.168.99.100:8082
      AUDIO_SAVE_PATH: /audio

      # MQTT Broker
      MQTT_BROKER_HOST: emqx
      MQTT_BROKER_PORT: 1883
      MQTT_CLIENT_ID: folotoy
      MQTT_USERNAME: folotoy
      MQTT_PASSWORD: folotoy

      SPEECH_UDP_SERVER_HOST: 192.168.99.100
      SPEECH_UDP_SERVER_PORT: 8085

      INTEGRATION_MQTT: true

roles.json

{
  "1": {
    "model": "gpt35turbo",
    "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
    "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-XiaoxiaoNeural",
    "language": "zh"
  },
  "2": {
    "model": "gpt35turbo",
    "start_text": "你好,俺是东北兔,请问有什么俺可以帮助你的吗?",
    "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“东北兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-liaoning-XiaobeiNeural",
    "language": "zh"
  },
  "3": {
    "model": "gpt35turbo",
    "start_text": "Hi, I'm Fofo. Nice to meet you.",
    "prompt": "Your name is \"Fofo\". Your task is to chat with me. Please respond in English, keeping your answers brief – no more than 50 words each time!",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "en-US-AnaNeural",
    "language": "en"
  },
  "4": {
    "model": "gpt35turbo",
    "start_text": "你好,额是陕西兔,请问有什么额可以帮助你的吗? ",
    "prompt": "你擅于鼓励别人,乐观积极,无论别人和你说了什么,你都能夸对方,让人快乐",
    "max_message_count": 10,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-shaanxi-XiaoniNeural",
    "language": "zh"
  },
  "5": {
    "model": "gpt35turbo",
    "start_text": "你好,我是童话故事兔,想听什么童话故事吗?试试说,我想听听三只小猫咪的故事",
    "prompt": "你是一个知识渊博的智能机器人,你的名字叫“故事兔”,你的任务是讲故事给一位7岁孩子的听,你要先听取孩子想听的故事主题,然后根据孩子的说的内容,用中文讲一段故事,每个故事不超过200个字!",
    "max_message_count": 10,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-XiaoyiNeural",
    "language": "zh"
  },
  "6": {
    "model": "gpt35turbo",
    "start_text": "你好,我是台湾兔,请问有什么我可以帮助你的吗?",
    "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“台湾兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
    "max_message_count": 10,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-TW-HsiaoChenNeural",
    "language": "zh"
  },
  "7": {
    "model": "gpt35turbo",
    "start_text": "你好,我是口算兔,我们一起来玩玩口算游戏吧?",
    "prompt": "我是一个6岁小朋友,你陪我玩口算游戏。你出题,我回答结果。如果答对了你就说好棒,答错了你就告诉我正确答案,并且鼓励我。你一题一题的出,我一个个回答。不要有太多的解释说明。明白了吗?",
    "max_message_count": 20,
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-YunxiaNeural",
    "language": "zh"
  }
}

另外 azure 的 whisper 需要单独申请和部署的,可以现在azure网站上测试一下是否可以使用 都已经单独部署了,本地通过 python 脚本测试是没有问题的。

@lewangdev

lewangdev commented 5 months ago

你用的azure的上的部署的whisper吗?STT_TYPE要设置为: azure-whisper

bluezd commented 5 months ago

把 STT_TYPE 改成 azure-whisper 也报错。 @lewangdev

folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,415 - DEBUG - Current dkey=fcb467da1104 role=2
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,416 - DEBUG - STT type: azure-whisper
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,418 - DEBUG - load_ssl_context verify=True cert=None trust_env=True http2=False
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,421 - DEBUG - load_verify_locations cafile='/usr/local/lib/python3.11/site-packages/certifi/cacert.pem'
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,460 - DEBUG - connect_tcp.started host='openai-jude.openai.azure.com' port=443 local_address=None timeout=20 socket_options=None
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,831 - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f853e5dd0>
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,832 - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0x7f85626720> server_hostname='openai-jude.openai.azure.com' timeout=20
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,836 - DEBUG - start_tls.failed exception=ConnectError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1006)'))
bluezd commented 5 months ago

另外,按 wifi 键的时候,没有声音提示,提示如下报错:

WARNING - Text to sound failed with: zh-CN-liaoning-XiaobeiNeural, text: 你好,俺是东北兔,请问有什么俺可以帮助你的吗?
lewangdev commented 5 months ago

zh-CN-liaoning-XiaobeiNeural

edge-tts不支持这个voice name,edge-tts是免费的,voice name 的列表会动态变化,可以换一个试试:https://docs.folotoy.com/zh/docs/configuration/tts/edge-tts

lewangdev commented 5 months ago

把 STT_TYPE 改成 azure-whisper 也报错。 @lewangdev

folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,415 - DEBUG - Current dkey=fcb467da1104 role=2
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,416 - DEBUG - STT type: azure-whisper
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,418 - DEBUG - load_ssl_context verify=True cert=None trust_env=True http2=False
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,421 - DEBUG - load_verify_locations cafile='/usr/local/lib/python3.11/site-packages/certifi/cacert.pem'
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,460 - DEBUG - connect_tcp.started host='openai-jude.openai.azure.com' port=443 local_address=None timeout=20 socket_options=None
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,831 - DEBUG - connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f853e5dd0>
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,832 - DEBUG - start_tls.started ssl_context=<ssl.SSLContext object at 0x7f85626720> server_hostname='openai-jude.openai.azure.com' timeout=20
folotoy-server-self-hosting-folotoy-1  | 2024-03-27 19:25:28,836 - DEBUG - start_tls.failed exception=ConnectError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1006)'))

请问你的宿主机器os是什么版本,看的是 ssl 问题,我目前还无法重现

bluezd commented 5 months ago

重现

树莓派中 docker 运行 folotoy-server, 我觉得是 docker 镜像中的问题比如 python Azure-OpenAI 的版本是不是有问题,我在树莓派上 host 中运行 python 脚本测试都是可以的。

uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ docker compose ps
NAME                                    IMAGE                                                                     COMMAND                                                         SERVICE   CREATED        STATUS         PORTS
folotoy-server-self-hosting-emqx-1      sha256:e8c8d9e64dbf16abbcc04caa0940b7ba81adb34b83e935066be4d1c71adcbb18   "/usr/bin/docker-entrypoint.sh /opt/emqx/bin/emqx foreground"   emqx      4 weeks ago    Up 6 minutes   4370/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5369/tcp, 8084/tcp, 0.0.0.0:8083->8083/tcp, :::8083->8083/tcp, 0.0.0.0:18083->18083/tcp, :::18083->18083/tcp, 8883/tcp
folotoy-server-self-hosting-folotoy-1   lewangdev/folotoy-server:latest                                           "python3 folotoy/main.py"                                       folotoy   16 hours ago   Up 6 minutes   0.0.0.0:8085->8085/udp, :::8085->8085/udp
folotoy-server-self-hosting-nginx-1     sha256:760b7cbba31e196288effd2af6924c42637ac5e0d67db4de6309f24518844676   "/docker-entrypoint.sh nginx -g 'daemon off;'"                  nginx     4 weeks ago    Up 7 minutes   0.0.0.0:8082->80/tcp, :::8082->80/tcp
bluezd commented 5 months ago

zh-CN-liaoning-XiaobeiNeural

edge-tts不支持这个voice name,edge-tts是免费的,voice name 的列表会动态变化,可以换一个试试:https://docs.folotoy.com/zh/docs/configuration/tts/edge-tts

改成 "zh-CN-XiaoxiaoNeural" 只有也不行,这里的 id 要怎么设置,我从日志上看要设置成 3

{
  "1": {
    "model": "gpt35turbo",
    "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
    "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
    "max_message_count": 20,
    "tts_type": "edge-tts",
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-XiaoxiaoNeural",
    "language": "zh"
  },
  "3": {
    "model": "gpt35turbo",
    "start_text": "你好,俺是东北兔,请问有什么俺可以帮助你的吗?",
    "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“东北兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
    "max_message_count": 20,
    "tts_type": "edge-tts",
    "temperature": 0.7,
    "max_tokens": 800,
    "top_p": 0.95,
    "frequency_penalty": 0,
    "presence_penalty": 0,
    "voice_name": "zh-CN-XiaoxiaoNeural",
    "language": "zh"
  }
}
lewangdev commented 5 months ago

roles.json 里面可以配置 1-7个角色,目前仙人掌应该只用到1-3,1-3都要设置好

{
    "1":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "2":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "3":
    {
        "model": "gpt35turbo",
        "start_text": "你好,俺是东北兔,请问有什么俺可以帮助你的吗?",
        "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“东北兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    }
}
lewangdev commented 5 months ago

重现

树莓派中 docker 运行 folotoy-server, 我觉得是 docker 镜像中的问题比如 python Azure-OpenAI 的版本是不是有问题,我在树莓派上 host 中运行 python 脚本测试都是可以的。

uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ docker compose ps
NAME                                    IMAGE                                                                     COMMAND                                                         SERVICE   CREATED        STATUS         PORTS
folotoy-server-self-hosting-emqx-1      sha256:e8c8d9e64dbf16abbcc04caa0940b7ba81adb34b83e935066be4d1c71adcbb18   "/usr/bin/docker-entrypoint.sh /opt/emqx/bin/emqx foreground"   emqx      4 weeks ago    Up 6 minutes   4370/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5369/tcp, 8084/tcp, 0.0.0.0:8083->8083/tcp, :::8083->8083/tcp, 0.0.0.0:18083->18083/tcp, :::18083->18083/tcp, 8883/tcp
folotoy-server-self-hosting-folotoy-1   lewangdev/folotoy-server:latest                                           "python3 folotoy/main.py"                                       folotoy   16 hours ago   Up 6 minutes   0.0.0.0:8085->8085/udp, :::8085->8085/udp
folotoy-server-self-hosting-nginx-1     sha256:760b7cbba31e196288effd2af6924c42637ac5e0d67db4de6309f24518844676   "/docker-entrypoint.sh nginx -g 'daemon off;'"                  nginx     4 weeks ago    Up 7 minutes   0.0.0.0:8082->80/tcp, :::8082->80/tcp

有可能是不匹配的问题,镜像用的是debian bullseye arm64的。Azure-OpenAI sdk 用的最新版的,方便到容器里面运行一下代码吗?

docker compose exec -it folotoy /bin/bash
lewangdev commented 5 months ago

请问树莓派访问azure接口时候是否经过代理了?

bluezd commented 5 months ago

重现

树莓派中 docker 运行 folotoy-server, 我觉得是 docker 镜像中的问题比如 python Azure-OpenAI 的版本是不是有问题,我在树莓派上 host 中运行 python 脚本测试都是可以的。

uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ docker compose ps
NAME                                    IMAGE                                                                     COMMAND                                                         SERVICE   CREATED        STATUS         PORTS
folotoy-server-self-hosting-emqx-1      sha256:e8c8d9e64dbf16abbcc04caa0940b7ba81adb34b83e935066be4d1c71adcbb18   "/usr/bin/docker-entrypoint.sh /opt/emqx/bin/emqx foreground"   emqx      4 weeks ago    Up 6 minutes   4370/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5369/tcp, 8084/tcp, 0.0.0.0:8083->8083/tcp, :::8083->8083/tcp, 0.0.0.0:18083->18083/tcp, :::18083->18083/tcp, 8883/tcp
folotoy-server-self-hosting-folotoy-1   lewangdev/folotoy-server:latest                                           "python3 folotoy/main.py"                                       folotoy   16 hours ago   Up 6 minutes   0.0.0.0:8085->8085/udp, :::8085->8085/udp
folotoy-server-self-hosting-nginx-1     sha256:760b7cbba31e196288effd2af6924c42637ac5e0d67db4de6309f24518844676   "/docker-entrypoint.sh nginx -g 'daemon off;'"                  nginx     4 weeks ago    Up 7 minutes   0.0.0.0:8082->80/tcp, :::8082->80/tcp

有可能是不匹配的问题,镜像用的是debian bullseye arm64的。Azure-OpenAI sdk 用的最新版的,方便到容器里面运行一下代码吗?

docker compose exec -it folotoy /bin/bash

exec 进入后执行什么呢?

image
bluezd commented 5 months ago

请问树莓派访问azure接口时候是否经过代理了?

无论代理关闭还是打开都不行。

bluezd commented 5 months ago

roles.json 里面可以配置 1-7个角色,目前仙人掌应该只用到1-3,1-3都要设置好

{
    "1":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "2":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "3":
    {
        "model": "gpt35turbo",
        "start_text": "你好,俺是东北兔,请问有什么俺可以帮助你的吗?",
        "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“东北兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    }
}

按照这个设置后,有如下报错:

folotoy-server-self-hosting-folotoy-1  | 2024-03-28 12:19:31,887 - DEBUG - Using selector: EpollSelector
folotoy-server-self-hosting-folotoy-1  | 2024-03-28 12:19:32,082 - WARNING - Text to sound failed with: zh-CN-XiaoxiaoNeural, text: 你好,俺是东北兔,请问有什么俺可以帮助你的吗?
folotoy-server-self-hosting-folotoy-1  | 2024-03-28 12:19:42,292 - DEBUG - Received /user/folotoy/fcb467da1104/thing/event/post: message data: {'msgId': 2, 'identifier': 'press_small_btn', 'outParams': {'keyCode': 4, 'changed': 1}}
folotoy-server-self-hosting-folotoy-1  | 2024-03-28 12:19:42,293 - DEBUG - Cannot find role config for sn=fcb467da1104, role=4
folotoy-server-self-hosting-folotoy-1  | Exception in thread paho-mqtt-client-folotoy:
folotoy-server-self-hosting-folotoy-1  | Traceback (most recent call last):
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
folotoy-server-self-hosting-folotoy-1  |     self.run()
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/threading.py", line 975, in run
folotoy-server-self-hosting-folotoy-1  |     self._target(*self._args, **self._kwargs)
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 4517, in _thread_main
folotoy-server-self-hosting-folotoy-1  |     self.loop_forever(retry_first_connection=True)
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 2291, in loop_forever
folotoy-server-self-hosting-folotoy-1  |     rc = self._loop(timeout)
folotoy-server-self-hosting-folotoy-1  |          ^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 1680, in _loop
folotoy-server-self-hosting-folotoy-1  |     rc = self.loop_read()
folotoy-server-self-hosting-folotoy-1  |          ^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 2094, in loop_read
folotoy-server-self-hosting-folotoy-1  |     rc = self._packet_read()
folotoy-server-self-hosting-folotoy-1  |          ^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3137, in _packet_read
folotoy-server-self-hosting-folotoy-1  |     rc = self._packet_handle()
folotoy-server-self-hosting-folotoy-1  |          ^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 3803, in _packet_handle
folotoy-server-self-hosting-folotoy-1  |     return self._handle_publish()
folotoy-server-self-hosting-folotoy-1  |            ^^^^^^^^^^^^^^^^^^^^^^
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 4140, in _handle_publish
folotoy-server-self-hosting-folotoy-1  |     self._handle_on_message(message)
folotoy-server-self-hosting-folotoy-1  |   File "/usr/local/lib/python3.11/site-packages/paho/mqtt/client.py", line 4496, in _handle_on_message
folotoy-server-self-hosting-folotoy-1  |     on_message(self, self._userdata, message)
folotoy-server-self-hosting-folotoy-1  |   File "core/folotoy_app.py", line 126, in core.folotoy_app.FolotoyApp.start.on_message
folotoy-server-self-hosting-folotoy-1  |   File "core/folotoy_app.py", line 97, in core.folotoy_app.FolotoyApp.process_mqtt_message
folotoy-server-self-hosting-folotoy-1  |   File "core/folotoy_msg_processor.py", line 169, in core.folotoy_msg_processor.FolotoyMsgProcessor.process_press_small_btn
folotoy-server-self-hosting-folotoy-1  | TypeError: 'NoneType' object is not iterable
folotoy-server-self-hosting-folotoy-1  | 2024-03-28 12:20:04,377 - DEBUG - Peer: ('192.168.99.127', 58645) Len: 20B
folotoy-server-self-hosting-folotoy-1  | 2024-03-28 12:20:04,378 - DEBUG - Received token: ad3db23dbb3f40ecbf354a48ba8beaef RecordingId: 4

看错误提示,需要设置5个角色,如果有类似的错误,可以把role按找1-7顺序多定义几个,目前最大不会超过7。仙人掌目前的固件部分应该是5个角色。

{
    "1":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "2":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "3":
    {
        "model": "gpt35turbo",
        "start_text": "你好,俺是东北兔,请问有什么俺可以帮助你的吗?",
        "prompt": "你是一个知识渊博,乐于助人的智能机器人,你的名字叫“东北兔”,你的任务是陪我聊天,请用简短的对话方式,用中文讲一段话,每次回答不超过50个字!",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "4":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    },
    "5":
    {
        "model": "gpt35turbo",
        "start_text": "你好,我是小兔兔,请问有什么我可以帮助你的吗?",
        "prompt": "你扮演一个孩子的小伙伴,名字叫小兔兔,性格和善,说话活泼可爱,对孩子充满爱心,经常赞赏和鼓励孩子,用5岁孩子容易理解语言提供有趣和创新的回答,每次回复根据聊天主题询问她的看法以激发她的思考和好奇心,现在她来到了你身边问了第一个问题:[你是谁]",
        "max_message_count": 20,
        "tts_type": "edge-tts",
        "temperature": 0.7,
        "max_tokens": 800,
        "top_p": 0.95,
        "frequency_penalty": 0,
        "presence_penalty": 0,
        "voice_name": "zh-CN-XiaoxiaoNeural",
        "language": "zh"
    }
}
lewangdev commented 5 months ago

重现

树莓派中 docker 运行 folotoy-server, 我觉得是 docker 镜像中的问题比如 python Azure-OpenAI 的版本是不是有问题,我在树莓派上 host 中运行 python 脚本测试都是可以的。

uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
$ docker compose ps
NAME                                    IMAGE                                                                     COMMAND                                                         SERVICE   CREATED        STATUS         PORTS
folotoy-server-self-hosting-emqx-1      sha256:e8c8d9e64dbf16abbcc04caa0940b7ba81adb34b83e935066be4d1c71adcbb18   "/usr/bin/docker-entrypoint.sh /opt/emqx/bin/emqx foreground"   emqx      4 weeks ago    Up 6 minutes   4370/tcp, 0.0.0.0:1883->1883/tcp, :::1883->1883/tcp, 5369/tcp, 8084/tcp, 0.0.0.0:8083->8083/tcp, :::8083->8083/tcp, 0.0.0.0:18083->18083/tcp, :::18083->18083/tcp, 8883/tcp
folotoy-server-self-hosting-folotoy-1   lewangdev/folotoy-server:latest                                           "python3 folotoy/main.py"                                       folotoy   16 hours ago   Up 6 minutes   0.0.0.0:8085->8085/udp, :::8085->8085/udp
folotoy-server-self-hosting-nginx-1     sha256:760b7cbba31e196288effd2af6924c42637ac5e0d67db4de6309f24518844676   "/docker-entrypoint.sh nginx -g 'daemon off;'"                  nginx     4 weeks ago    Up 7 minutes   0.0.0.0:8082->80/tcp, :::8082->80/tcp

有可能是不匹配的问题,镜像用的是debian bullseye arm64的。Azure-OpenAI sdk 用的最新版的,方便到容器里面运行一下代码吗?

docker compose exec -it folotoy /bin/bash

exec 进入后执行什么呢? image

我用树莓派测试一下,等有结果了再发出来。

在容器里面,可以执行一下你的 Python 代码,用容器里面的Python环境

bluezd commented 5 months ago

我用树莓派测试一下,等有结果了再发出来。

在容器里面,可以执行一下你的 Python 代码,用容器里面的Python环境

我测试了, 在容器里执行失败:

import os
from openai import AzureOpenAI

client = AzureOpenAI(
    api_key=os.getenv("AZURE_OPENAI_API_KEY"),
    api_version="2024-02-01",
    azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
)

deployment_id = "whisper" #This will correspond to the custom name you chose for your deployment when you deployed a model."
audio_test_file = "./wikipediaOcelot.wav"

result = client.audio.transcriptions.create(
    file=open(audio_test_file, "rb"),
    model=deployment_id
)

print(result)
root@04e621baf015:/# python whisper-1.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
    yield
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 233, in handle_request
    resp = self._pool.handle_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
    raise exc from None
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
    response = connection.handle_request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 99, in handle_request
    raise exc
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 76, in handle_request
    stream = self._connect(request)
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_sync/connection.py", line 154, in _connect
    stream = stream.start_tls(**kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/sync.py", line 152, in start_tls
    with map_exceptions(exc_map):
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpcore/_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: EOF occurred in violation of protocol (_ssl.c:1006)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 926, in _request
    response = self._client.send(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 914, in send
    response = self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 942, in _send_handling_auth
    response = self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 979, in _send_handling_redirects
    response = self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1015, in _send_single_request
    response = transport.handle_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 232, in handle_request
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: EOF occurred in violation of protocol (_ssl.c:1006)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "//whisper-1.py", line 13, in <module>
    result = client.audio.transcriptions.create(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/resources/audio/transcriptions.py", line 115, in create
    return self._post(
           ^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1208, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 897, in request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 950, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1021, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 950, in _request
    return self._retry_request(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1021, in _retry_request
    return self._request(
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 960, in _request
    raise APIConnectionError(request=request) from err
openai.APIConnectionError: Connection error.
lewangdev commented 5 months ago

那可能是基础镜像有啥兼容问题了,看报错的地方是ssl相关的,目前我们打包用qemu虚拟环境打包的,amd64目前没有这个问题,arm64得再看看了,暂时不能确定问题在哪里了,等我setup和你一样的环境再进行下一步测试

另外是不是所有https都会报错?

bluezd commented 5 months ago

那可能是基础镜像有啥兼容问题了,看报错的地方是ssl相关的,目前我们打包用qemu虚拟环境打包的,amd64目前没有这个问题,arm64得再看看了,暂时不能确定问题在哪里了,等我setup和你一样的环境再进行下一步测试

另外是不是所有https都会报错?

其他的没测试,我估计也是同样的问题。

那我先切换到默认的环境上,等您这边修复好了,我再试一下。麻烦有结果尽快通知我下。

bluezd commented 5 months ago

另外,如何切换到默认的提供的免费额度的服务器上?尝试长按 wifi 键,试了很多次没有看到 wifi 弹出来。

lewangdev commented 5 months ago

另外,如何切换到默认的提供的免费额度的服务器上?尝试长按 wifi 键,试了很多次没有看到 wifi 弹出来。

  1. 尝试把手机Wi-Fi关闭再开一下,看看能不能搜到folotoy开头的热点

  2. 也可以用at指令来,用usb线连接玩具与电脑,需要安装一下串口驱动,然后参考这里修改:https://docs.folotoy.com/zh/docs/at-command

例如修改 mqtt

at+config=mqtt,broker,;port, // at+config=mqtt,broker,192.168.52.1;port,1883

lewangdev commented 5 months ago

另外,如何切换到默认的提供的免费额度的服务器上?尝试长按 wifi 键,试了很多次没有看到 wifi 弹出来。

如果方便,这是仙人掌核心用户的交流群

image

bluezd commented 5 months ago

另外,如何切换到默认的提供的免费额度的服务器上?尝试长按 wifi 键,试了很多次没有看到 wifi 弹出来。

如果方便,这是仙人掌核心用户的交流群

image

已加入

bluezd commented 5 months ago

请问有进展吗?

lewangdev commented 5 months ago

请问有进展吗?

今天会出来结果,我们在用最新的树莓派64位固件做测试

lewangdev commented 5 months ago

经过测试,固件 2024-03-15-raspios-bookworm-arm64.img 可以正常工作

root@raspberrypi:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@raspberrypi:~# uname -na
Linux raspberrypi 6.6.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux
bluezd commented 5 months ago

@lewangdev 把你测试的所需要的配置文件发我一份看下?

bluezd commented 5 months ago

我使用你发的版本重试了一次,拉取镜像报错:

$ docker pull lewangdev/folotoy-server:latest
latest: Pulling from lewangdev/folotoy-server
no matching manifest for linux/arm/v8 in the manifest list entries
lewangdev commented 5 months ago

@lewangdev 把你测试的所需要的配置文件发我一份看下?

用的项目默认的配置文件,与x86版本没什么区别。

我刚出差了,等我回去发给你,我用自己的树莓派4b测试的

lewangdev commented 5 months ago

我使用你发的版本重试了一次,拉取镜像报错:

$ docker pull lewangdev/folotoy-server:latest
latest: Pulling from lewangdev/folotoy-server
no matching manifest for linux/arm/v8 in the manifest list entries

有点奇怪,arm64 镜像是有的。

image

https://hub.docker.com/repository/docker/lewangdev/folotoy-server/tags

bluezd commented 5 months ago

更换镜像之后,问题就解决了 ...