yihong0618 / xiaogpt

Play ChatGPT and other LLM with Xiaomi AI Speaker
MIT License
6.28k stars 878 forks source link

File "/Users/amber/Work/xiaomiGPT/xiaogpt/xiaogpt.py", line 456, in <module> raise Exception(f"{options.config} doesn't exist") #60

Closed MasterWangBo closed 1 year ago

MasterWangBo commented 1 year ago

在根据视频教程的最后运行python3 xiaogpt.py --hardware LX04 --use_chatgpt_api --mute_xiaoai

出现以下报错提示

Traceback (most recent call last): File "/Users/amber/Work/xiaomiGPT/xiaogpt/xiaogpt.py", line 456, in <module> raise Exception(f"{options.config} doesn't exist") Exception: xiaogptconfig.json doesn't exist

yihong0618 commented 1 year ago

我们看看,稍等,可能有 bug @pjq

yihong0618 commented 1 year ago

@MasterWangBo 修复了

git pull 然后重新试一下

MasterWangBo commented 1 year ago

@MasterWangBo 修复了

git pull 然后重新试一下

好的,这次拉完代码重新走这段代码确实没有报错了,但是发现前面绑定did的小爱音箱并没有响应这段识别,然后控制台出现以下报错:

`amber@wangbodeM1-Max-MacBook-Pro xiaogpt % python3 xiaogpt.py --hardware LX04 --use_chatgpt_api --mute_xiaoai

Running xiaogpt now, 用帮我问开头来提问

Traceback (most recent call last):

File "/Users/amber/Work/xiaomiGPT/xiaogpt/xiaogpt.py", line 482, in asyncio.run(miboy.run_forever()) File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/Users/amber/Work/xiaomiGPT/xiaogpt/xiaogpt.py", line 333, in run_forever await self.stop_if_xiaoai_is_playing() File "/Users/amber/Work/xiaomiGPT/xiaogpt/xiaogpt.py", line 307, in stop_if_xiaoai_is_playing is_playing = await self.get_if_xiaoai_is_playing() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/amber/Work/xiaomiGPT/xiaogpt/xiaogpt.py", line 298, in get_if_xiaoai_is_playing playing_info = await self.mina_service.player_get_status(self.device_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/miservice/minaservice.py", line 68, in player_get_status return await self.ubus_request( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/miservice/minaservice.py", line 32, in ubus_request result = await self.mina_request( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/miservice/minaservice.py", line 22, in mina_request return await self.account.mi_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/miservice/miaccount.py", line 149, in mi_request raise Exception(f"Error {url}: {resp}")

Exception: Error https://api2.mina.mi.com/remote/ubus: {'code': 101, 'message': 'ubus server or device returned invalid result', 'data': {'device_data': '{"msg":"ROM端未响应","code":3012}', 'reqID': 'app_ios_SdO6rbJpDeWMUtcuxom5klfw7AHQX2'}}`

yihong0618 commented 1 year ago

确保开启了蓝牙,如果设备不支持 ubus 可能无法mute xiaomi

pjq commented 1 year ago

@yihong0618 感谢修复上面crash的问题 我之前发现config.json和revChatGPT库里面默认读的配置文件冲突了,所以我们的配置文件不能和config.json同名了 所以改成了xiaogptconfig.json

yihong0618 commented 1 year ago

得改个名我到家改,刚在跑步

MasterWangBo commented 1 year ago

确保开启了蓝牙,如果设备不支持 ubus 可能无法mute xiaomi

嗯,刚刚又去确定了一下蓝牙是开启的,也手动关闭后又开启了,尝试唤醒后还是这个日志,设备是LX04,小米触屏音箱4寸版

pjq commented 1 year ago

你命令行执行下面这个命令,能听到声音吗 micli 5-1 "你好"

MasterWangBo commented 1 year ago

micli 5-1 "你好"

不能听到,控制台日志如下

`amber@wangbodeM1-Max-MacBook-Pro xiaogpt % micli 5-1 "你好"

Get Props: /opt/homebrew/bin/micli <siid[-piid]>[,...] /opt/homebrew/bin/micli 1,1-2,1-3,1-4,2-1,2-2,3 Set Props: /opt/homebrew/bin/micli <siid[-piid]=[#]value>[,...] /opt/homebrew/bin/micli 2=#60,2-2=#false,3=test Do Action: /opt/homebrew/bin/micli <siid[-piid]> <arg1|#NA> [...] /opt/homebrew/bin/micli 2 #NA /opt/homebrew/bin/micli 5 Hello /opt/homebrew/bin/micli 5-4 Hello #1

Call MIoT: /opt/homebrew/bin/micli /opt/homebrew/bin/micli action '{"did":"267090026","siid":5,"aiid":1,"in":["Hello"]}'

Call MiIO: /opt/homebrew/bin/micli / /opt/homebrew/bin/micli /home/device_list '{"getVirtualModel":false,"getHuamiDevices":1}'

Devs List: /opt/homebrew/bin/micli list [name=full|name_keyword] [getVirtualModel=false|true] [getHuamiDevices=0|1] /opt/homebrew/bin/micli list Light true 0

MIoT Spec: /opt/homebrew/bin/micli spec [model_keyword|type_urn] [format=text|python|json] /opt/homebrew/bin/micli spec /opt/homebrew/bin/micli spec speaker /opt/homebrew/bin/micli spec xiaomi.wifispeaker.lx04 /opt/homebrew/bin/micli spec urn:miot-spec-v2:device:speaker:0000A015:xiaomi-lx04:1

MIoT Decode: /opt/homebrew/bin/micli decode [gzip]`

yihong0618 commented 1 year ago

看日志触屏版好像不行,我调研下哈,现在在外面

MasterWangBo commented 1 year ago

看日志触屏版好像不行,我调研下哈,现在在外面

嗯嗯好的,家里目前4个触屏的小爱音箱,2个4寸的LX04,2个8寸的X08C,估计这个也不行,还有一个不是触屏的设备是Xiaomi Sound,型号L16A,,我试试那个


ps,L16A的Xiaomi Sound也无法正常唤醒,控制台目前也没有报错,奇怪了。。

pjq commented 1 year ago

你可以看看这个命令的输出 micli spec urn:miot-spec-v2:device🔈0000A015:xiaomi-lx04:1

MasterWangBo commented 1 year ago

micli spec urn:miot-spec-v2:device🔈0000A015:xiaomi-lx04:1

amber@wangbodeM1-Max-MacBook-Pro xiaogpt % micli spec urn:miot-spec-v2:device🔈0000A015:xiaomi-lx04:1 0, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url=URL('http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device%F0%9F%94%880000A015:xiaomi-lx04:1')

pjq commented 1 year ago

好像这个可以看到 micli spec xiaomi.wifispeaker.lx04;

# Generated by https://github.com/Yonsm/MiService
# http://miot-spec.org/miot-spec-v2/instance?type=urn:miot-spec-v2:device:speaker:0000A015:xiaomi-lx04:2

Device_Information = 1
    Device_Manufacturer = 1
    Device_Model = 2
    Device_Serial_Number = 3
    Current_Firmware_Version = 4

Speaker = 2
    Volume = 1  # uint8  # rw
    Mute = 2  # bool  # rw

Play_Control = 3
    _Playing_State = 1  # uint8  # n

    _Play = 1
    _Pause = 2
    _Next = 3
    _Previous = 4

Microphone = 4
    Mute = 1  # bool  # rw

Intelligent_Speaker = 5
    _Text_Content = 1
    _Silent_Execution = 2  # uint8
    Sleep_Mode = 3  # bool  # rwn
    Audio_Id = 4  # rn

    _Play_Text = 1  # in=[1]
    _Wake_Up = 2  # in=[1]
    _Play_Radio = 3
    _Execute_Text_Directive = 4  # in=[1, 2]

Clock = 6

    _Stop_Alarm = 1

Speaker_Volume
    MIN = 5
    MAX = 100

Play_Control_Playing_State
    Stop = 0
    Playing = 1
    Pause = 2

Intelligent_Speaker_Silent_Execution
    On = 0
    Off = 1
MasterWangBo commented 1 year ago

micli spec xiaomi.wifispeaker.lx04

是的,我这边输入后也是这样

`Device_Information = 1 Device_Manufacturer = 1 Device_Model = 2 Device_Serial_Number = 3 Current_Firmware_Version = 4

Speaker = 2 Volume = 1 # uint8 # rw Mute = 2 # bool # rw

Play_Control = 3 _Playing_State = 1 # uint8 # n

_Play = 1
_Pause = 2
_Next = 3
_Previous = 4

Microphone = 4 Mute = 1 # bool # rw

Intelligent_Speaker = 5 _Text_Content = 1 _Silent_Execution = 2 # uint8 Sleep_Mode = 3 # bool # rwn Audio_Id = 4 # rn

_Play_Text = 1  # in=[1]
_Wake_Up = 2  # in=[1]
_Play_Radio = 3
_Execute_Text_Directive = 4  # in=[1, 2]

Clock = 6

_Stop_Alarm = 1

Speaker_Volume MIN = 5 MAX = 100

Play_Control_Playing_State Stop = 0 Playing = 1 Pause = 2

Intelligent_Speaker_Silent_Execution On = 0 Off = 1`

yihong0618 commented 1 year ago

micli 5-1 "你好"

不能听到,控制台日志如下

`amber@wangbodeM1-Max-MacBook-Pro xiaogpt % micli 5-1 "你好"

Get Props: /opt/homebrew/bin/micli <siid[-piid]>[,...] /opt/homebrew/bin/micli 1,1-2,1-3,1-4,2-1,2-2,3 Set Props: /opt/homebrew/bin/micli <siid[-piid]=[#]value>[,...] /opt/homebrew/bin/micli 2=#60,2-2=#false,3=test Do Action: /opt/homebrew/bin/micli <siid[-piid]> <arg1|#NA> [...] /opt/homebrew/bin/micli 2 #NA /opt/homebrew/bin/micli 5 Hello /opt/homebrew/bin/micli 5-4 Hello #1

Call MIoT: /opt/homebrew/bin/micli /opt/homebrew/bin/micli action '{"did":"267090026","siid":5,"aiid":1,"in":["Hello"]}'

Call MiIO: /opt/homebrew/bin/micli / /opt/homebrew/bin/micli /home/device_list '{"getVirtualModel":false,"getHuamiDevices":1}'

Devs List: /opt/homebrew/bin/micli list [name=full|name_keyword] [getVirtualModel=false|true] [getHuamiDevices=0|1] /opt/homebrew/bin/micli list Light true 0

MIoT Spec: /opt/homebrew/bin/micli spec [model_keyword|type_urn] [format=text|python|json] /opt/homebrew/bin/micli spec /opt/homebrew/bin/micli spec speaker /opt/homebrew/bin/micli spec xiaomi.wifispeaker.lx04 /opt/homebrew/bin/micli spec urn:miot-spec-v2:device🔈0000A015:xiaomi-lx04:1

MIoT Decode: /opt/homebrew/bin/micli decode [gzip]`

你是不没设置 DID

MasterWangBo commented 1 year ago

micli 5-1 "你好"

不能听到,控制台日志如下 amber@wangbodeM1-Max-MacBook-Pro xiaogpt % micli 5-1 "你好" Get Props: /opt/homebrew/bin/micli <siid[-piid]>[,...] /opt/homebrew/bin/micli 1,1-2,1-3,1-4,2-1,2-2,3 Set Props: /opt/homebrew/bin/micli <siid[-piid]=[#]value>[,...] /opt/homebrew/bin/micli 2=#60,2-2=#false,3=test Do Action: /opt/homebrew/bin/micli <siid[-piid]> <arg1|#NA> [...] /opt/homebrew/bin/micli 2 #NA /opt/homebrew/bin/micli 5 Hello /opt/homebrew/bin/micli 5-4 Hello #1 Call MIoT: /opt/homebrew/bin/micli <cmd=prop/get|/prop/set|action> /opt/homebrew/bin/micli action '{"did":"267090026","siid":5,"aiid":1,"in":["Hello"]}' Call MiIO: /opt/homebrew/bin/micli / /opt/homebrew/bin/micli /home/device_list '{"getVirtualModel":false,"getHuamiDevices":1}' Devs List: /opt/homebrew/bin/micli list [name=full|name_keyword] [getVirtualModel=false|true] [getHuamiDevices=0|1] /opt/homebrew/bin/micli list Light true 0 MIoT Spec: /opt/homebrew/bin/micli spec [model_keyword|type_urn] [format=text|python|json] /opt/homebrew/bin/micli spec /opt/homebrew/bin/micli spec speaker /opt/homebrew/bin/micli spec xiaomi.wifispeaker.lx04 /opt/homebrew/bin/micli spec urn:miot-spec-v2:device🔈0000A015:xiaomi-lx04:1 MIoT Decode: /opt/homebrew/bin/micli decode [gzip]

你是不没设置 DID

设置了的,照着视频教程里在MiService里做的

amber@wangbodeM1-Max-MacBook-Pro MiService % export MI_DID=6xxxxx

yihong0618 commented 1 year ago

参考 #70 试试?

MasterWangBo commented 1 year ago

参考 #70 试试?

我的情况还和他的情况不一样,他是之前一直能收到gpt回复,我这边现在是运行指令后 提示 amber@wangbodeM1-Max-MacBook-Pro xiaogpt % python3 xiaogpt.py --use_chatgpt_api --hardware LX04 --use_command Running xiaogpt now, 用帮我开头来提问 这个后就没反应了,终端也没有新的指令输出了。

也尝试运行了 python3 xiaogpt.py --use_chatgpt_api --hardware LX04 --use_command 这句指令,还是一样

pjq commented 1 year ago

拉最新的代码再试试看?