xiaogpt 2.63__py3-none-any.whl → 2.64__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xiaogpt/config.py +3 -1
- xiaogpt/tts/tetos.py +8 -33
- xiaogpt/xiaogpt.py +7 -1
- {xiaogpt-2.63.dist-info → xiaogpt-2.64.dist-info}/METADATA +38 -38
- {xiaogpt-2.63.dist-info → xiaogpt-2.64.dist-info}/RECORD +8 -8
- {xiaogpt-2.63.dist-info → xiaogpt-2.64.dist-info}/WHEEL +0 -0
- {xiaogpt-2.63.dist-info → xiaogpt-2.64.dist-info}/entry_points.txt +0 -0
- {xiaogpt-2.63.dist-info → xiaogpt-2.64.dist-info}/licenses/LICENSE +0 -0
xiaogpt/config.py
CHANGED
@@ -76,7 +76,9 @@ class Config:
|
|
76
76
|
start_conversation: str = "开始持续对话"
|
77
77
|
end_conversation: str = "结束持续对话"
|
78
78
|
stream: bool = False
|
79
|
-
tts: Literal[
|
79
|
+
tts: Literal[
|
80
|
+
"mi", "edge", "azure", "openai", "baidu", "google", "volc", "minimax"
|
81
|
+
] = "mi"
|
80
82
|
tts_options: dict[str, Any] = field(default_factory=dict)
|
81
83
|
gpt_options: dict[str, Any] = field(default_factory=dict)
|
82
84
|
bing_cookie_path: str = ""
|
xiaogpt/tts/tetos.py
CHANGED
@@ -4,7 +4,6 @@ import tempfile
|
|
4
4
|
from pathlib import Path
|
5
5
|
|
6
6
|
from miservice import MiNAService
|
7
|
-
from tetos.base import Speaker
|
8
7
|
|
9
8
|
from xiaogpt.config import Config
|
10
9
|
from xiaogpt.tts.base import AudioFileTTS
|
@@ -14,39 +13,15 @@ class TetosTTS(AudioFileTTS):
|
|
14
13
|
def __init__(
|
15
14
|
self, mina_service: MiNAService, device_id: str, config: Config
|
16
15
|
) -> None:
|
17
|
-
|
18
|
-
self.speaker = self._get_speaker()
|
19
|
-
|
20
|
-
def _get_speaker(self) -> Speaker:
|
21
|
-
from tetos.azure import AzureSpeaker
|
22
|
-
from tetos.baidu import BaiduSpeaker
|
23
|
-
from tetos.edge import EdgeSpeaker
|
24
|
-
from tetos.google import GoogleSpeaker
|
25
|
-
from tetos.openai import OpenAISpeaker
|
26
|
-
from tetos.volc import VolcSpeaker
|
16
|
+
from tetos import get_speaker
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
GoogleSpeaker,
|
36
|
-
BaiduSpeaker,
|
37
|
-
):
|
38
|
-
if (name := speaker.__name__[:-7].lower()) == self.config.tts:
|
39
|
-
try:
|
40
|
-
return speaker(**options)
|
41
|
-
except TypeError as e:
|
42
|
-
raise ValueError(
|
43
|
-
f"{e}. Please add them via `tts_options` config"
|
44
|
-
) from e
|
45
|
-
else:
|
46
|
-
allowed_speakers.append(name)
|
47
|
-
raise ValueError(
|
48
|
-
f"Unsupported TTS: {self.config.tts}, allowed: {','.join(allowed_speakers)}"
|
49
|
-
)
|
18
|
+
super().__init__(mina_service, device_id, config)
|
19
|
+
assert config.tts and config.tts != "mi"
|
20
|
+
speaker_cls = get_speaker(config.tts)
|
21
|
+
try:
|
22
|
+
self.speaker = speaker_cls(**config.tts_options)
|
23
|
+
except TypeError as e:
|
24
|
+
raise ValueError(f"{e}. Please add them via `tts_options` config") from e
|
50
25
|
|
51
26
|
async def make_audio_file(self, lang: str, text: str) -> tuple[Path, float]:
|
52
27
|
output_file = tempfile.NamedTemporaryFile(
|
xiaogpt/xiaogpt.py
CHANGED
@@ -418,9 +418,15 @@ class MiGPT:
|
|
418
418
|
# It is not a legal language code, discard it
|
419
419
|
lang, first_chunk = "", text
|
420
420
|
|
421
|
+
lang = (
|
422
|
+
matches[0]
|
423
|
+
if (matches := re.findall(r"([a-z]{2}-[A-Z]{2})", lang))
|
424
|
+
else "zh-CN"
|
425
|
+
)
|
426
|
+
|
421
427
|
async def gen(): # reconstruct the generator
|
422
428
|
yield first_chunk
|
423
429
|
async for text in text_stream:
|
424
430
|
yield text
|
425
431
|
|
426
|
-
await self.tts.synthesize(lang
|
432
|
+
await self.tts.synthesize(lang, gen())
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: xiaogpt
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.64
|
4
4
|
Summary: Play ChatGPT or other LLM with xiaomi AI speaker
|
5
5
|
Author-Email: yihong0618 <zouzou0208@gmail.com>
|
6
6
|
License: MIT
|
@@ -22,7 +22,7 @@ Requires-Dist: google-search-results>=2.4.2
|
|
22
22
|
Requires-Dist: google-generativeai
|
23
23
|
Requires-Dist: numexpr>=2.8.6
|
24
24
|
Requires-Dist: dashscope>=1.10.0
|
25
|
-
Requires-Dist: tetos>=0.
|
25
|
+
Requires-Dist: tetos>=0.2.1
|
26
26
|
Requires-Dist: aiohttp==3.9.5; extra == "locked"
|
27
27
|
Requires-Dist: aiosignal==1.3.1; extra == "locked"
|
28
28
|
Requires-Dist: annotated-types==0.6.0; extra == "locked"
|
@@ -102,7 +102,7 @@ Requires-Dist: socksio==1.0.0; extra == "locked"
|
|
102
102
|
Requires-Dist: soupsieve==2.5; extra == "locked"
|
103
103
|
Requires-Dist: sqlalchemy==2.0.25; extra == "locked"
|
104
104
|
Requires-Dist: tenacity==8.2.3; extra == "locked"
|
105
|
-
Requires-Dist: tetos==0.
|
105
|
+
Requires-Dist: tetos==0.2.1; extra == "locked"
|
106
106
|
Requires-Dist: tqdm==4.66.1; extra == "locked"
|
107
107
|
Requires-Dist: typing-extensions==4.9.0; extra == "locked"
|
108
108
|
Requires-Dist: typing-inspect==0.9.0; extra == "locked"
|
@@ -195,7 +195,7 @@ xiaogpt --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key}
|
|
195
195
|
# 如果你想使用自己的 google gemini 服务
|
196
196
|
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key} --gemini_api_domain ${gemini_api_domain}
|
197
197
|
# 如果你想使用阿里的通义千问
|
198
|
-
xiaogpt --hardware LX06 --mute_xiaoai --use_qwen --
|
198
|
+
xiaogpt --hardware LX06 --mute_xiaoai --use_qwen --qwen_key ${qwen_key}
|
199
199
|
# 如果你想使用豆包
|
200
200
|
xiaogpt --hardware LX06 --mute_xiaoai --use_doubao --stream --volc_access_key xxxx --volc_secret_key xxx
|
201
201
|
# 如果你想用 edge-tts
|
@@ -226,7 +226,7 @@ python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${ge
|
|
226
226
|
# 如果你想使用自己的 google gemini 服务
|
227
227
|
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_gemini --gemini_key ${gemini_key} --gemini_api_domain ${gemini_api_domain}
|
228
228
|
# 如果你想使用阿里的通义千问
|
229
|
-
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_qwen --
|
229
|
+
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_qwen --qwen_key ${qwen_key}
|
230
230
|
# 如果你想使用豆包
|
231
231
|
python3 xiaogpt.py --hardware LX06 --mute_xiaoai --use_doubao --stream --volc_access_key xxxx --volc_secret_key xxx
|
232
232
|
# 如果你想使用 LangChain+SerpApi 实现上网检索或其他本地服务(目前仅支持 stream 模式)
|
@@ -272,39 +272,39 @@ ChatGLM [文档](http://open.bigmodel.cn/doc/api#chatglm_130b)
|
|
272
272
|
|
273
273
|
## 配置项说明
|
274
274
|
|
275
|
-
| 参数 | 说明 | 默认值 | 可选值
|
276
|
-
| --------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
277
|
-
| hardware | 设备型号 | |
|
278
|
-
| account | 小爱账户 | |
|
279
|
-
| password | 小爱账户密码 | |
|
280
|
-
| openai_key | openai的apikey | |
|
281
|
-
| serpapi_api_key | serpapi的key 参考 [SerpAPI](https://serpapi.com/) | |
|
282
|
-
| glm_key | chatglm 的 apikey | |
|
283
|
-
| gemini_key | gemini 的 apikey [参考](https://makersuite.google.com/app/apikey) | |
|
284
|
-
| gemini_api_domain
|
285
|
-
| qwen_key | qwen 的 apikey [参考](https://help.aliyun.com/zh/dashscope/developer-reference/api-details) | |
|
286
|
-
| cookie | 小爱账户cookie (如果用上面密码登录可以不填) | |
|
287
|
-
| mi_did | 设备did | |
|
288
|
-
| use_command | 使用 MI command 与小爱交互 | `false` |
|
289
|
-
| mute_xiaoai | 快速停掉小爱自己的回答 | `true` |
|
290
|
-
| verbose | 是否打印详细日志 | `false` |
|
291
|
-
| bot | 使用的 bot 类型,目前支持 chatgptapi,newbing, qwen, gemini | `chatgptapi` |
|
292
|
-
| tts | 使用的 TTS 类型 | `mi` | `edge`、 `openai`、`azure`、`volc`、`baidu`、`google` |
|
293
|
-
| tts_options | TTS 参数字典,参考 [tetos](https://github.com/frostming/tetos) 获取可用参数 | |
|
294
|
-
| prompt | 自定义prompt | `请用100字以内回答` |
|
295
|
-
| keyword | 自定义请求词列表 | `["请"]` |
|
296
|
-
| change_prompt_keyword | 更改提示词触发列表 | `["更改提示词"]` |
|
297
|
-
| start_conversation | 开始持续对话关键词 | `开始持续对话` |
|
298
|
-
| end_conversation | 结束持续对话关键词 | `结束持续对话` |
|
299
|
-
| stream | 使用流式响应,获得更快的响应 | `false` |
|
300
|
-
| proxy | 支持 HTTP 代理,传入 http proxy URL | "" |
|
301
|
-
| gpt_options | OpenAI API 的参数字典 | `{}` |
|
302
|
-
| bing_cookie_path | NewBing使用的cookie路径,参考[这里]获取 | 也可通过环境变量 `COOKIE_FILE` 设置 |
|
303
|
-
| bing_cookies | NewBing使用的cookie字典,参考[这里]获取 | |
|
304
|
-
| deployment_id | Azure OpenAI 服务的 deployment ID | 参考这个[如何找到deployment_id](https://github.com/yihong0618/xiaogpt/issues/347#issuecomment-1784410784) |
|
305
|
-
| api_base | 如果需要替换默认的api,或者使用Azure OpenAI 服务 | 例如:`https://abc-def.openai.azure.com/` |
|
306
|
-
| volc_access_key | 火山引擎的 access key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | |
|
307
|
-
| volc_secret_key | 火山引擎的 secret key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | |
|
275
|
+
| 参数 | 说明 | 默认值 | 可选值 |
|
276
|
+
| --------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
|
277
|
+
| hardware | 设备型号 | | |
|
278
|
+
| account | 小爱账户 | | |
|
279
|
+
| password | 小爱账户密码 | | |
|
280
|
+
| openai_key | openai的apikey | | |
|
281
|
+
| serpapi_api_key | serpapi的key 参考 [SerpAPI](https://serpapi.com/) | | |
|
282
|
+
| glm_key | chatglm 的 apikey | | |
|
283
|
+
| gemini_key | gemini 的 apikey [参考](https://makersuite.google.com/app/apikey) | | |
|
284
|
+
| gemini_api_domain | gemini 的自定义域名 [参考](https://github.com/antergone/palm-netlify-proxy) | |
|
285
|
+
| qwen_key | qwen 的 apikey [参考](https://help.aliyun.com/zh/dashscope/developer-reference/api-details) | | |
|
286
|
+
| cookie | 小爱账户cookie (如果用上面密码登录可以不填) | | |
|
287
|
+
| mi_did | 设备did | | |
|
288
|
+
| use_command | 使用 MI command 与小爱交互 | `false` | |
|
289
|
+
| mute_xiaoai | 快速停掉小爱自己的回答 | `true` | |
|
290
|
+
| verbose | 是否打印详细日志 | `false` | |
|
291
|
+
| bot | 使用的 bot 类型,目前支持 chatgptapi,newbing, qwen, gemini | `chatgptapi` | |
|
292
|
+
| tts | 使用的 TTS 类型 | `mi` | `edge`、 `openai`、`azure`、`volc`、`baidu`、`google`、`minimax` |
|
293
|
+
| tts_options | TTS 参数字典,参考 [tetos](https://github.com/frostming/tetos) 获取可用参数 | | |
|
294
|
+
| prompt | 自定义prompt | `请用100字以内回答` | |
|
295
|
+
| keyword | 自定义请求词列表 | `["请"]` | |
|
296
|
+
| change_prompt_keyword | 更改提示词触发列表 | `["更改提示词"]` | |
|
297
|
+
| start_conversation | 开始持续对话关键词 | `开始持续对话` | |
|
298
|
+
| end_conversation | 结束持续对话关键词 | `结束持续对话` | |
|
299
|
+
| stream | 使用流式响应,获得更快的响应 | `false` | |
|
300
|
+
| proxy | 支持 HTTP 代理,传入 http proxy URL | "" | |
|
301
|
+
| gpt_options | OpenAI API 的参数字典 | `{}` | |
|
302
|
+
| bing_cookie_path | NewBing使用的cookie路径,参考[这里]获取 | 也可通过环境变量 `COOKIE_FILE` 设置 | |
|
303
|
+
| bing_cookies | NewBing使用的cookie字典,参考[这里]获取 | | |
|
304
|
+
| deployment_id | Azure OpenAI 服务的 deployment ID | 参考这个[如何找到deployment_id](https://github.com/yihong0618/xiaogpt/issues/347#issuecomment-1784410784) | |
|
305
|
+
| api_base | 如果需要替换默认的api,或者使用Azure OpenAI 服务 | 例如:`https://abc-def.openai.azure.com/` |
|
306
|
+
| volc_access_key | 火山引擎的 access key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | |
|
307
|
+
| volc_secret_key | 火山引擎的 secret key 请在[这里](https://console.volcengine.com/iam/keymanage/)获取 | | |
|
308
308
|
[这里]: https://github.com/acheong08/EdgeGPT#getting-authentication-required
|
309
309
|
|
310
310
|
## 注意
|
@@ -1,7 +1,7 @@
|
|
1
|
-
xiaogpt-2.
|
2
|
-
xiaogpt-2.
|
3
|
-
xiaogpt-2.
|
4
|
-
xiaogpt-2.
|
1
|
+
xiaogpt-2.64.dist-info/METADATA,sha256=Fe0CPFakH6tK89iEDBxseiRnS-LUZvHBJrmiM_n0YcU,28654
|
2
|
+
xiaogpt-2.64.dist-info/WHEEL,sha256=7sv5iXvIiTVJSnAxCz2tGBm9DHsb2vPSzeYeT7pvGUY,90
|
3
|
+
xiaogpt-2.64.dist-info/entry_points.txt,sha256=zLFzA72qQ_eWBepdA2YU5vdXFqORH8wXhv2Ox1vnYP8,46
|
4
|
+
xiaogpt-2.64.dist-info/licenses/LICENSE,sha256=XdClh516MvlnOf9749JZHCxSB7y6_fyXcWmLDz6IkZY,1063
|
5
5
|
xiaogpt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
xiaogpt/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
|
7
7
|
xiaogpt/bot/__init__.py,sha256=kOIY1lR0r-tbrnlcv_lj3cXxcwM4UpM8THxQ-JrRfwM,1006
|
@@ -14,7 +14,7 @@ xiaogpt/bot/langchain_bot.py,sha256=4Uz5iOYzA2ongCklS-9zBse2fw-7kEE_9wITH7wdVCc,
|
|
14
14
|
xiaogpt/bot/newbing_bot.py,sha256=afUmw6tyMXbgGZvfQQWaA5h0-e0V0isFolW-WGhd0Vs,2289
|
15
15
|
xiaogpt/bot/qwen_bot.py,sha256=325lMa4Z38rRh47HDa3J4XjvSs4SWOqMVhrMWzkGNo4,3657
|
16
16
|
xiaogpt/cli.py,sha256=TcdMjk95vven3BmHAPFYSBe1rHKVfbEcc4PF6wHbyDw,4956
|
17
|
-
xiaogpt/config.py,sha256
|
17
|
+
xiaogpt/config.py,sha256=-fzcnlB5nsbHCh8mcH9112Pyafacj-E94fjokJKyiBM,6560
|
18
18
|
xiaogpt/langchain/callbacks.py,sha256=yR9AXQt9OHVYBWC47Q1I_BUT4Xg9iM44vnW2vv0BLpE,2616
|
19
19
|
xiaogpt/langchain/chain.py,sha256=z0cqRlL0ElWnf31ByxZBN7AKOT-svXQDt5_NDft_nYc,1495
|
20
20
|
xiaogpt/langchain/examples/email/mail_box.py,sha256=xauqrjE4-G4XPQnokUPE-MZgAaHQ_VrUDLlbfYTdCoo,6372
|
@@ -22,7 +22,7 @@ xiaogpt/langchain/examples/email/mail_summary_tools.py,sha256=6cWvBJUaA7iaywcHdb
|
|
22
22
|
xiaogpt/tts/__init__.py,sha256=xasHDrmgECirf1MSyrfURSaMBqtdZBi3cQNeDvPo_cQ,145
|
23
23
|
xiaogpt/tts/base.py,sha256=fljxdXy60HXqdLXyQlsJZtzJBo5VtTwLkkWTi58tzQc,4656
|
24
24
|
xiaogpt/tts/mi.py,sha256=1MzCB27DBohPQ_4Xz4W_FV9p-chJFDavOHB89NviLcM,1095
|
25
|
-
xiaogpt/tts/tetos.py,sha256=
|
25
|
+
xiaogpt/tts/tetos.py,sha256=fkuOSYGqAfJyyPEXbsiOS--CewGf1JUiahoN33nzOAA,1058
|
26
26
|
xiaogpt/utils.py,sha256=B7NCH7g19hcwHDXsnBJPTU6UcWnXoEntKWm-pgcet2I,2072
|
27
|
-
xiaogpt/xiaogpt.py,sha256=
|
28
|
-
xiaogpt-2.
|
27
|
+
xiaogpt/xiaogpt.py,sha256=PUONfYNrghc-4LuAyki_fAhKeyISCF_URWhUoa0ncIk,15960
|
28
|
+
xiaogpt-2.64.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|