Skip to content

Commit 9292e18

Browse files
committed
添加了TTS,ble的接口描述
1 parent 63dcf1a commit 9292e18

File tree

2 files changed

+231
-0
lines changed

2 files changed

+231
-0
lines changed

quecpython_stubs/audio.pyi

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,133 @@ class Record(object):
309309
"""
310310

311311
AMRNB: int = ... # AMR format.
312+
313+
class TTS(object):
314+
"""Class Text-to-speech playback.
315+
316+
Currently supported models: EC600N series, EC800N series, EC600M-CN (LA, LE), EC800M-CN (LA, LE, GA), EG810MCN_GA, EC600U series, EC200U series, EG912U, EG915U, EG915N-EUAG.
317+
Description: https://developer.quectel.com/doc/quecpython/API_reference/zh/medialib/audio.TTS.html
318+
"""
319+
320+
def __init__(self, device):
321+
"""Creates an TTS object.
322+
323+
:param device: Integer type. The output channel. 0 indicates earpiece, 1 indicates headphone, and 2 indicates speaker. See the table below for the specific channels supported by each module.
324+
Channels Supported by the Module:
325+
Module Earpiece Headphone Speaker
326+
EC200N/EC600N/EC800N Supported Unsupported Unsupported
327+
EC600M-CN(LA/LE) Supported Unsupported Unsupported
328+
EC800M-CN(LA/LE/GA) Supported Unsupported Unsupported
329+
EG810M Supported Unsupported Unsupported
330+
EG915N/EG912N Supported Unsupported Unsupported
331+
EG912U Supported Unsupported Unsupported
332+
EC200U Unsupported Unsupported Supported
333+
EC600U Supported Supported Supported
334+
EG915U Supported Supported Unsupported
335+
EC600S Supported Unsupported Unsupported
336+
EC600K/EC800K Supported Unsupported Unsupported
337+
EC800G-CN(GA/TT/LA) Supported Supported Supported
338+
EC600G-CN(LA) Supported Supported Supported
339+
"""
340+
341+
def close(self):
342+
"""This method disables the TTS function.
343+
344+
:return: 0 - Successful execution; -1 - Failed execution.
345+
"""
346+
347+
def play(self, priority, breakin, mode, str):
348+
"""This method starts TTS playback. For usage examples, click here.
349+
350+
The playback task scheduling follows priority and break-in rules:
351+
- Higher priority tasks (0-4, 4=highest) can interrupt lower priority ones
352+
- Each priority group supports up to 10 queued tasks
353+
- Break-in mode determines if current playback can be interrupted
354+
355+
:param priority: Integer type. Play priority (0-4). Higher value = higher priority.
356+
:param breakin: Integer type. Break-in mode. 0: not allowed to break in; 1: allowed to break in.
357+
:param mode: Integer type. Play mode (lower 4 bits: encoding mode; higher 4 bits: WTTS mode). See TTS mode table.
358+
:param str: String type. The string to be played.
359+
:return: Returns an integer value.
360+
0 - Playback started successfully
361+
-1 - Playback failed
362+
1 - Added to playback queue (cannot play immediately)
363+
-2 - Priority group queue full (not added)
364+
"""
365+
366+
def stop(self):
367+
"""This method stops TTS playback.
368+
369+
:return: 0 indicates success, -1 indicates failure.
370+
"""
371+
372+
def stopAll(self):
373+
"""This method stops the entire playback queue.
374+
375+
If TTS or audio is currently playing and there are other contents in the queue,
376+
calling this method will not only stop the current playback but also clear the queue.
377+
If currently playing and the playback queue is empty, this method has the same effect as stop().
378+
379+
:return: 0 indicates success, -1 indicates failure.
380+
"""
381+
382+
def setCallback(self, cb):
383+
"""This method registers a user callback function to notify TTS playback status.
384+
385+
Do not perform time-consuming or blocking operations in the callback function.
386+
It is recommended to only perform simple and short operations.
387+
388+
:param cb: User callback function, function type. Function prototype:
389+
def cb(event):
390+
pass
391+
392+
Callback function parameter description:
393+
event - Playback status, int type:
394+
2 - Playback started
395+
3 - Playback stopped
396+
4 - Playback completed
397+
398+
:return: 0 indicates success, -1 indicates failure.
399+
"""
400+
401+
def getVolume(self):
402+
"""This method gets the current playback volume level.
403+
404+
Volume value range [0 ~ 9], where 0 indicates mute (default is 4).
405+
406+
:return: Integer volume value on success, -1 on failure.
407+
"""
408+
409+
def setVolume(self, vol):
410+
"""This method sets the playback volume level.
411+
412+
Volume value should be in the range [0 ~ 9], where 0 indicates mute.
413+
414+
:param vol: Volume level, int type, range [0 ~ 9].
415+
:return: 0 indicates success, -1 indicates failure.
416+
"""
417+
418+
def getSpeed(self):
419+
"""This method gets the current playback speed.
420+
421+
Speed value range [0 ~ 9], higher values indicate faster speed (default is 4).
422+
423+
:return: Integer speed value on success, -1 on failure.
424+
"""
425+
426+
def setSpeed(self, speed):
427+
"""This method sets the TTS playback speed.
428+
429+
Speed value should be in the range [0 ~ 9].
430+
431+
:param speed: Speed value, int type, range [0 ~ 9].
432+
:return: 0 indicates success, -1 indicates failure.
433+
"""
434+
435+
def getState(self):
436+
"""This method gets the TTS status.
437+
438+
:return:
439+
0 - No TTS playback currently
440+
-1 - TTS is currently playing
441+
"""

quecpython_stubs/ble.pyi

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,104 @@ def writeCharaDesc(connect_id, handle, data):
546546
:param data:Bytearray type. Characteristic description data.
547547
:return:0- Successful execution; -1- Failed execution.
548548
"""
549+
550+
551+
def exchangeMtu(self, connect_id, mtu_size):
552+
"""Send MTU exchange request.
553+
554+
The MTU exchange request should be initiated by the client side.
555+
556+
:param connect_id: Connection ID, obtained when establishing the connection, integer type.
557+
:param mtu_size: MTU size.
558+
:return: 0 on success, -1 on failure.
559+
"""
560+
561+
def smpSetConfig(self, io_cap, auth_req, passkey, timeout):
562+
"""Configure pairing capabilities.
563+
564+
Pairing method selection process:
565+
There are two modes for BLE SMP pairing: Legacy Pairing and Secure Connections Pairing.
566+
The specific pairing method is determined through negotiation between the two parties after
567+
exchanging their IO capabilities.
568+
569+
:param io_cap: Device input/output capability, integer type, default 3.
570+
Value Meaning
571+
0 Display only, can display PIN code
572+
1 Display only, can only display Yes/No, cannot display PIN code
573+
2 Input only, can input PIN code
574+
3 No input/output capability (default)
575+
4 Both input and output capabilities
576+
:param auth_req: Authentication request parameter, integer type, default 9.
577+
Bit0 Bit1 Bit2 Bit3
578+
0 No binding after pairing Reserved Disable MITM Use Legacy Pairing
579+
1 Bind after pairing Reserved Enable MITM Use Secure Connections Pairing
580+
:param passkey: PIN code to display during pairing, integer type, default 123456.
581+
:param timeout: Pairing timeout, in units of 100ms, integer type, default 160.
582+
:return: 0 on success, -1 on failure.
583+
"""
584+
585+
def smpGetConfig(self):
586+
"""Query pairing capabilities.
587+
588+
:return: On success, returns a tuple (io_cap, auth_req, passkey, timeout).
589+
On failure, returns -1.
590+
591+
io_cap - Device input/output capability, integer type, default 3.
592+
Value Meaning
593+
0 Display only, can display PIN code
594+
1 Display only, can only display Yes/No, cannot display PIN code
595+
2 Input only, can input PIN code
596+
3 No input/output capability
597+
4 Both input and output capabilities
598+
auth_req - Authentication request parameter, integer type, default 9.
599+
Bit0 Bit1 Bit2 Bit3
600+
0 No binding after pairing Reserved Disable MITM Use Legacy Pairing
601+
1 Bind after pairing Reserved Enable MITM Use Secure Connections Pairing
602+
passkey - PIN code to display during pairing, integer type, default 123456.
603+
timeout - Pairing timeout, in units of 100ms, integer type, default 160.
604+
"""
605+
606+
def smpStartPair(self, connect_id):
607+
"""Start the BLE SMP pairing process.
608+
609+
SMP pairing is initiated by the client, but the server can also use this interface
610+
to notify the client to initiate an SMP pairing request.
611+
612+
:param connect_id: Connection ID, obtained when establishing the connection, integer type.
613+
:return: 0 on success, -1 on failure.
614+
"""
615+
616+
def smpUserConfirm(self, connect_id, pair_operation, pin):
617+
"""Confirm pairing.
618+
619+
After receiving a pairing request, confirm whether to accept the pairing.
620+
621+
:param connect_id: Connection ID, obtained when establishing the connection, integer type.
622+
:param pair_operation: Pairing operation type, integer type.
623+
Value Meaning
624+
0 Cancel pairing (only available during pairing process; will disconnect the BLE connection)
625+
1 Confirm pairing without PIN (for Just Work or Numeric Comparison modes)
626+
2 Confirm pairing with PIN (for Passkey mode)
627+
:param pin: PIN code, integer type.
628+
:return: 0 on success, -1 on failure.
629+
"""
630+
631+
def smpGetPairedDevInfo(self):
632+
"""Get information about paired devices.
633+
634+
:return: On success, returns a list of bytearray objects representing BLE addresses of paired devices.
635+
On failure, returns -1.
636+
"""
637+
638+
def smpRemovePairedDev(self, addr):
639+
"""Delete information for a specified paired device.
640+
641+
:param addr: BLE address of the device to be deleted, bytearray type (6 bytes).
642+
:return: 0 on success, -1 on failure.
643+
"""
644+
645+
def smpCleanPairedDev(self):
646+
"""Delete information for all paired devices.
647+
648+
:return: 0 on success, -1 on failure.
649+
"""

0 commit comments

Comments
 (0)