reykit 1.0.1__py3-none-any.whl → 1.1.1__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.
Files changed (60) hide show
  1. reydb/__init__.py +1 -1
  2. reydb/rbuild.py +44 -44
  3. reydb/rconnection.py +107 -107
  4. reydb/rexecute.py +9 -13
  5. reydb/rfile.py +8 -8
  6. reydb/rinformation.py +13 -25
  7. reydb/rparameter.py +10 -10
  8. reykit/__init__.py +1 -1
  9. reykit/rcomm.py +12 -12
  10. reykit/rdata.py +4 -4
  11. reykit/remail.py +12 -14
  12. reykit/rexception.py +4 -4
  13. reykit/rimage.py +9 -9
  14. reykit/rlog.py +30 -30
  15. reykit/rmonkey.py +4 -5
  16. reykit/rmultitask.py +14 -15
  17. reykit/rnumber.py +2 -2
  18. reykit/ros.py +21 -21
  19. reykit/rrandom.py +11 -11
  20. reykit/rregex.py +10 -13
  21. reykit/rschedule.py +10 -10
  22. reykit/rstdout.py +13 -13
  23. reykit/rsystem.py +224 -30
  24. reykit/rtable.py +31 -31
  25. reykit/rtext.py +3 -3
  26. reykit/rtime.py +11 -31
  27. reykit/rtype.py +2 -2
  28. reykit/rwrap.py +16 -16
  29. reykit/rzip.py +4 -5
  30. {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/METADATA +1 -1
  31. reykit-1.1.1.dist-info/RECORD +38 -0
  32. reykit-1.0.1.dist-info/RECORD +0 -64
  33. reyweb/__init__.py +0 -19
  34. reyweb/rall.py +0 -12
  35. reyweb/rbaidu/__init__.py +0 -21
  36. reyweb/rbaidu/rbaidu_base.py +0 -186
  37. reyweb/rbaidu/rbaidu_chat.py +0 -299
  38. reyweb/rbaidu/rbaidu_image.py +0 -183
  39. reyweb/rbaidu/rbaidu_voice.py +0 -256
  40. reywechat/__init__.py +0 -32
  41. reywechat/data/client_api.dll +0 -0
  42. reywechat/rall.py +0 -20
  43. reywechat/rclient.py +0 -912
  44. reywechat/rdatabase.py +0 -1189
  45. reywechat/rexception.py +0 -65
  46. reywechat/rexecute.py +0 -201
  47. reywechat/rlog.py +0 -198
  48. reywechat/rreceive.py +0 -1232
  49. reywechat/rschedule.py +0 -136
  50. reywechat/rsend.py +0 -630
  51. reywechat/rwechat.py +0 -201
  52. reyworm/__init__.py +0 -24
  53. reyworm/rall.py +0 -16
  54. reyworm/rbrowser.py +0 -134
  55. reyworm/rcalendar.py +0 -159
  56. reyworm/rnews.py +0 -126
  57. reyworm/rsecurity.py +0 -239
  58. reyworm/rtranslate.py +0 -75
  59. {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/WHEEL +0 -0
  60. {reykit-1.0.1.dist-info → reykit-1.1.1.dist-info}/top_level.txt +0 -0
@@ -1,256 +0,0 @@
1
- # !/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @Time : 2024-01-11 22:00:14
6
- @Author : Rey
7
- @Contact : reyxbo@163.com
8
- @Explain : Baidu API voice methods.
9
- """
10
-
11
-
12
- from typing import Optional
13
- from reykit.rexception import warn
14
- from reykit.ros import RFile
15
- from reykit.rtime import wait
16
-
17
- from .rbaidu_base import RAPIBaidu
18
-
19
-
20
- __all__ = (
21
- 'RAPIBaiduVoice',
22
- )
23
-
24
-
25
- class RAPIBaiduVoice(RAPIBaidu):
26
- """
27
- Rey's `Baidu API voice` type.
28
- """
29
-
30
-
31
- def to_file(
32
- self,
33
- text: str,
34
- path: Optional[str] = None
35
- ) -> bytes:
36
- """
37
- Generate voice file from text.
38
-
39
- Parameters
40
- ----------
41
- text : Text, length cannot exceed 60.
42
- path : File save path.
43
- - `None`: Not save.
44
-
45
- Returns
46
- -------
47
- Voice bytes data.
48
- """
49
-
50
- # Check.
51
- if len(text) > 60:
52
- text = text[:60]
53
- warn('parameter "text" length cannot exceed 60')
54
-
55
- # Get parameter.
56
- url = 'https://tsn.baidu.com/text2audio'
57
- headers = {
58
- 'Accept': '*/*',
59
- 'Content-Type': 'application/x-www-form-urlencoded'
60
- }
61
- data = {
62
- 'tok': self.token,
63
- 'tex': text,
64
- 'cuid': self.cuid,
65
- 'ctp': 1,
66
- 'lan': 'zh',
67
- 'spd': 5,
68
- 'pit': 5,
69
- 'vol': 5,
70
- 'per': 4,
71
- 'aue': 3
72
- }
73
-
74
- # Request.
75
- response = self.request(
76
- url,
77
- data=data,
78
- headers=headers
79
- )
80
-
81
- # Record.
82
- self.record_call(
83
- text=text,
84
- path=path
85
- )
86
-
87
- # Extract.
88
- file_bytes = response.content
89
-
90
- # Save.
91
- if path is not None:
92
- rfile = RFile(path)
93
- rfile.write(file_bytes)
94
-
95
- return file_bytes
96
-
97
-
98
- def _to_url_create_task(
99
- self,
100
- text: str
101
- ) -> str:
102
- """
103
- Create task of generate voice URL from text.
104
-
105
- Parameters
106
- ----------
107
- text : Text, length cannot exceed 60.
108
-
109
- Returns
110
- -------
111
- Task ID.
112
- """
113
-
114
- # Get parameter.
115
- url = 'https://aip.baidubce.com/rpc/2.0/tts/v1/create'
116
- params = {'access_token': self.token}
117
- headers = {
118
- 'Accept': 'application/json',
119
- 'Content-Type': 'application/json'
120
- }
121
- json = {
122
- 'text': text,
123
- 'format': 'mp3-16k',
124
- 'voice': 4,
125
- 'lang': 'zh',
126
- 'speed': 5,
127
- 'pitch': 5,
128
- 'volume': 5,
129
- 'enable_subtitle': 0
130
- }
131
-
132
- # Request.
133
- response = self.request(
134
- url,
135
- params=params,
136
- json=json,
137
- headers=headers
138
- )
139
-
140
- # Record.
141
- self.record_call(text=text)
142
-
143
- # Extract.
144
- response_json: dict = response.json()
145
- task_id: str = response_json['task_id']
146
-
147
- return task_id
148
-
149
-
150
- def _to_url_query_task(
151
- self,
152
- task_id: str
153
- ) -> dict:
154
- """
155
- Query task of generate voice URL from text.
156
-
157
- Parameters
158
- ----------
159
- task_id : Task ID.
160
-
161
- Returns
162
- -------
163
- Task information.
164
- """
165
-
166
- # Get parameter.
167
- url = 'https://aip.baidubce.com/rpc/2.0/tts/v1/query'
168
- params = {'access_token': self.token}
169
- headers = {
170
- 'Accept': 'application/json',
171
- 'Content-Type': 'application/json'
172
- }
173
- json = {'task_ids': [task_id]}
174
-
175
- # Request.
176
- response = self.request(
177
- url,
178
- params=params,
179
- json=json,
180
- headers=headers
181
- )
182
-
183
- # Extract.
184
- response_json: dict = response.json()
185
- task_info: dict = response_json['tasks_info'][0]
186
-
187
- return task_info
188
-
189
-
190
- def to_url(
191
- self,
192
- text: str,
193
- path: Optional[str] = None
194
- ) -> str:
195
- """
196
- Generate voice URL from text.
197
-
198
- Parameters
199
- ----------
200
- text : Text, length cannot exceed 60.
201
- path : File save path.
202
- - `None`: Not save.
203
-
204
- Returns
205
- -------
206
- Voice URL.
207
- """
208
-
209
- # Create.
210
- task_id = self._to_url_create_task(text)
211
-
212
- # Wait.
213
- store = {}
214
-
215
-
216
- ## Define.
217
- def is_task_success() -> bool:
218
- """
219
- Whether if is task successed.
220
-
221
- Returns
222
- -------
223
- Judge result.
224
- """
225
-
226
- # Query.
227
- task_info = self._to_url_query_task(task_id)
228
-
229
- # Judge.
230
- match task_info['task_status']:
231
- case 'Running':
232
- return False
233
- case 'Success':
234
- store['url'] = task_info['task_result']['speech_url']
235
- return True
236
- case _:
237
- raise AssertionError('Baidu API text to voice task failed', task_info)
238
-
239
-
240
- ## Start.
241
- wait(
242
- is_task_success,
243
- _interval=0.5,
244
- _timeout=600
245
- )
246
-
247
- ## Extract.
248
- url = store['url']
249
-
250
- # Save.
251
- if path is not None:
252
- response = self.request(url)
253
- rfile = RFile(path)
254
- rfile.write(response.content)
255
-
256
- return url
reywechat/__init__.py DELETED
@@ -1,32 +0,0 @@
1
- # !/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @Time : 2023-10-17 20:24:04
6
- @Author : Rey
7
- @Contact : reyxbo@163.com
8
- @Explain : Rey's WeChat method set.
9
-
10
- Folders
11
- -------
12
- data : Data file.
13
-
14
- Modules
15
- -------
16
- rall : All methods.
17
- rclient : Client methods.
18
- rdatabase : Database methods.
19
- rexception : Exception methods.
20
- rexecute: Execute methods.
21
- rlog : Log methods.
22
- rreceive : Receive methods.
23
- rschedule : Schedule methods.
24
- rsend : Send methods.
25
- rwechat : WeChat methods.
26
- """
27
-
28
-
29
- from typing import Final
30
-
31
-
32
- __version__: Final[str] = '1.0.0'
Binary file
reywechat/rall.py DELETED
@@ -1,20 +0,0 @@
1
- # !/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @Time : 2023-10-19 11:40:35
6
- @Author : Rey
7
- @Contact : reyxbo@163.com
8
- @Explain : All methods.
9
- """
10
-
11
-
12
- from .rclient import *
13
- from .rdatabase import *
14
- from .rexception import *
15
- from .rexecute import *
16
- from .rlog import *
17
- from .rreceive import *
18
- from .rschedule import *
19
- from .rsend import *
20
- from .rwechat import *