xfyun-client
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -22,2 +22,6 @@ import { BehaviorSubject, Subject, Observable } from 'rxjs'; | ||
protected $chunked: Observable<Uint8Array>; | ||
/** | ||
* Messages to send to WebSocket | ||
*/ | ||
protected $message: Subject<string>; | ||
protected Option(): O; | ||
@@ -40,2 +44,3 @@ protected Response(): Res; | ||
send16kBuffer(buffer: Float32Array): Promise<void>; | ||
send16BitPCMBuffer(buffer: Uint8Array): Promise<void>; | ||
complete(): Promise<Res>; | ||
@@ -42,0 +47,0 @@ connect(): Promise<void>; |
@@ -1,1 +0,1 @@ | ||
import{a}from"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{a as ApiConnection}; | ||
import{a}from"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{a as ApiConnection}; |
@@ -1,1 +0,1 @@ | ||
import"../chunk-JZND3VTD.js";import{a as d}from"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import{a as b}from"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import{a as c}from"../chunk-TU3JZGTL.js";import{a}from"../chunk-LIPHC4AO.js";export{d as ApiConnection,a as ApiConnectionStatus,b as ApiOption,c as ApiResponse}; | ||
import"../chunk-JZND3VTD.js";import{a as d}from"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import{a as b}from"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import{a as c}from"../chunk-TU3JZGTL.js";import{a}from"../chunk-LIPHC4AO.js";export{d as ApiConnection,a as ApiConnectionStatus,b as ApiOption,c as ApiResponse}; |
@@ -12,2 +12,2 @@ interface AuthOption { | ||
export { ApiOption, AuthOption }; | ||
export { ApiOption, type AuthOption }; |
@@ -8,2 +8,2 @@ interface ApiRequest { | ||
export { ApiRequest, ApiRequestData }; | ||
export type { ApiRequest, ApiRequestData }; |
@@ -1,1 +0,1 @@ | ||
import{a}from"../chunk-IPFGOT62.js";import"../chunk-EQKNTHBH.js";import"../chunk-UYF2DHYU.js";import"../chunk-JZND3VTD.js";import"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{a as IatConnection}; | ||
import{a}from"../chunk-YAWKRTZW.js";import"../chunk-EQKNTHBH.js";import"../chunk-UYF2DHYU.js";import"../chunk-JZND3VTD.js";import"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{a as IatConnection}; |
@@ -1,1 +0,1 @@ | ||
import"../chunk-E5GULNMT.js";import"../chunk-D55QM667.js";import{a as d}from"../chunk-IPFGOT62.js";import{a}from"../chunk-EQKNTHBH.js";import{a as b,b as c}from"../chunk-UYF2DHYU.js";import"../chunk-JZND3VTD.js";import"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{d as IatConnection,a as IatOption,c as IatResponse,b as IatResponseDataStatus}; | ||
import"../chunk-E5GULNMT.js";import"../chunk-D55QM667.js";import{a as d}from"../chunk-YAWKRTZW.js";import{a}from"../chunk-EQKNTHBH.js";import{a as b,b as c}from"../chunk-UYF2DHYU.js";import"../chunk-JZND3VTD.js";import"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{d as IatConnection,a as IatOption,c as IatResponse,b as IatResponseDataStatus}; |
@@ -43,2 +43,2 @@ type IatRequestBusinessLanguage = 'zh_cn' | 'en_us'; | ||
export { IatRequest, IatRequest1, IatRequest2, IatRequestBusiness, IatRequestBusinessAccent, IatRequestBusinessDomain, IatRequestBusinessDwa, IatRequestBusinessEncoding, IatRequestBusinessLanguage, IatRequestBusinessPd, IatRequestBusinessRlang, IatRequestBusinessSampleRate, IatRequestCommon, IatRequestData }; | ||
export type { IatRequest, IatRequest1, IatRequest2, IatRequestBusiness, IatRequestBusinessAccent, IatRequestBusinessDomain, IatRequestBusinessDwa, IatRequestBusinessEncoding, IatRequestBusinessLanguage, IatRequestBusinessPd, IatRequestBusinessRlang, IatRequestBusinessSampleRate, IatRequestCommon, IatRequestData }; |
@@ -32,2 +32,2 @@ import { ApiResponse } from '../api/response.js'; | ||
export { IatResponse, IatResponseData, IatResponseDataStatus, IatResponseResult, IatResponseResultWord, IatResponseResultWordContent }; | ||
export { IatResponse, type IatResponseData, IatResponseDataStatus, type IatResponseResult, type IatResponseResultWord, type IatResponseResultWordContent }; |
@@ -1,1 +0,1 @@ | ||
import{a,b}from"../chunk-UYF2DHYU.js";import"../chunk-JZND3VTD.js";import"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{b as IatResponse,a as IatResponseDataStatus}; | ||
import{a,b}from"../chunk-UYF2DHYU.js";import"../chunk-JZND3VTD.js";import"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{b as IatResponse,a as IatResponseDataStatus}; |
@@ -1,1 +0,1 @@ | ||
import"./chunk-E5GULNMT.js";import"./chunk-D55QM667.js";import"./chunk-DGPTPROM.js";import{a as i}from"./chunk-TONVZCBN.js";import{a as g,b as h}from"./chunk-GU2EGRFS.js";import{a as d}from"./chunk-HMTOY2UQ.js";import"./chunk-BSEC2ZXW.js";import{a as n}from"./chunk-IPFGOT62.js";import{a as j}from"./chunk-EQKNTHBH.js";import{a as k,b as l}from"./chunk-UYF2DHYU.js";import"./chunk-JZND3VTD.js";import{a as c}from"./chunk-YLM6PNIL.js";import{a,b}from"./chunk-W4BRMK4G.js";import{a as o}from"./chunk-7ZEMB3HS.js";import{a as f}from"./chunk-N5NFW233.js";import{a as r,b as e}from"./chunk-IMAYVM2Y.js";import{a as x}from"./chunk-NP4EEY2K.js";import{a as p}from"./chunk-JDCMXEEN.js";import"./chunk-DYKUDQHN.js";import{a as t}from"./chunk-TU3JZGTL.js";import{a as m}from"./chunk-LIPHC4AO.js";export{c as ApiConnection,m as ApiConnectionStatus,p as ApiOption,t as ApiResponse,n as IatConnection,j as IatOption,l as IatResponse,k as IatResponseDataStatus,i as IseConnection,d as IseOption,h as IseResponse,g as IseResponseDataStatus,b as chuckDelay,a as chuckLength,e as from16BitPCM,o as resample,f as splitInChunks,r as to16BitPCM,x as toBase64}; | ||
import"./chunk-E5GULNMT.js";import"./chunk-D55QM667.js";import"./chunk-DGPTPROM.js";import{a as i}from"./chunk-2LTLCENN.js";import{a as g,b as h}from"./chunk-GU2EGRFS.js";import{a as d}from"./chunk-HMTOY2UQ.js";import"./chunk-BSEC2ZXW.js";import{a as n}from"./chunk-YAWKRTZW.js";import{a as j}from"./chunk-EQKNTHBH.js";import{a as k,b as l}from"./chunk-UYF2DHYU.js";import"./chunk-JZND3VTD.js";import{a as c}from"./chunk-OIGXPLZC.js";import{a,b}from"./chunk-W4BRMK4G.js";import{a as o}from"./chunk-7ZEMB3HS.js";import{a as f}from"./chunk-N5NFW233.js";import{a as r,b as e}from"./chunk-IMAYVM2Y.js";import{a as x}from"./chunk-NP4EEY2K.js";import{a as p}from"./chunk-JDCMXEEN.js";import"./chunk-DYKUDQHN.js";import{a as t}from"./chunk-TU3JZGTL.js";import{a as m}from"./chunk-LIPHC4AO.js";export{c as ApiConnection,m as ApiConnectionStatus,p as ApiOption,t as ApiResponse,n as IatConnection,j as IatOption,l as IatResponse,k as IatResponseDataStatus,i as IseConnection,d as IseOption,h as IseResponse,g as IseResponseDataStatus,b as chuckDelay,a as chuckLength,e as from16BitPCM,o as resample,f as splitInChunks,r as to16BitPCM,x as toBase64}; |
@@ -1,1 +0,1 @@ | ||
import{a}from"../chunk-TONVZCBN.js";import"../chunk-GU2EGRFS.js";import"../chunk-HMTOY2UQ.js";import"../chunk-JZND3VTD.js";import"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{a as IseConnection}; | ||
import{a}from"../chunk-2LTLCENN.js";import"../chunk-GU2EGRFS.js";import"../chunk-HMTOY2UQ.js";import"../chunk-JZND3VTD.js";import"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{a as IseConnection}; |
@@ -1,1 +0,1 @@ | ||
import"../chunk-DGPTPROM.js";import{a as d}from"../chunk-TONVZCBN.js";import{a as b,b as c}from"../chunk-GU2EGRFS.js";import{a}from"../chunk-HMTOY2UQ.js";import"../chunk-BSEC2ZXW.js";import"../chunk-JZND3VTD.js";import"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{d as IseConnection,a as IseOption,c as IseResponse,b as IseResponseDataStatus}; | ||
import"../chunk-DGPTPROM.js";import{a as d}from"../chunk-2LTLCENN.js";import{a as b,b as c}from"../chunk-GU2EGRFS.js";import{a}from"../chunk-HMTOY2UQ.js";import"../chunk-BSEC2ZXW.js";import"../chunk-JZND3VTD.js";import"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{d as IseConnection,a as IseOption,c as IseResponse,b as IseResponseDataStatus}; |
@@ -59,2 +59,2 @@ type IseRequestBusinessLanguage = 'zh_vip' | 'en_vip'; | ||
export { IseRequest, IseRequest1, IseRequest2, IseRequestBusiness1, IseRequestBusiness2, IseRequestBusiness4, IseRequestBusinessCategory, IseRequestBusinessCheckType, IseRequestBusinessEncoding, IseRequestBusinessExtraAbility, IseRequestBusinessGrade, IseRequestBusinessGroup, IseRequestBusinessLanguage, IseRequestBusinessRst, IseRequestBusinessSampleRate, IseRequestCommon, IseRequestData }; | ||
export type { IseRequest, IseRequest1, IseRequest2, IseRequestBusiness1, IseRequestBusiness2, IseRequestBusiness4, IseRequestBusinessCategory, IseRequestBusinessCheckType, IseRequestBusinessEncoding, IseRequestBusinessExtraAbility, IseRequestBusinessGrade, IseRequestBusinessGroup, IseRequestBusinessLanguage, IseRequestBusinessRst, IseRequestBusinessSampleRate, IseRequestCommon, IseRequestData }; |
@@ -17,2 +17,2 @@ import { ApiResponse } from '../api/response.js'; | ||
export { IseResponse, IseResponseData, IseResponseDataStatus }; | ||
export { IseResponse, type IseResponseData, IseResponseDataStatus }; |
@@ -1,1 +0,1 @@ | ||
import{a,b}from"../chunk-GU2EGRFS.js";import"../chunk-JZND3VTD.js";import"../chunk-YLM6PNIL.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{b as IseResponse,a as IseResponseDataStatus}; | ||
import{a,b}from"../chunk-GU2EGRFS.js";import"../chunk-JZND3VTD.js";import"../chunk-OIGXPLZC.js";import"../chunk-W4BRMK4G.js";import"../chunk-7ZEMB3HS.js";import"../chunk-N5NFW233.js";import"../chunk-IMAYVM2Y.js";import"../chunk-NP4EEY2K.js";import"../chunk-JDCMXEEN.js";import"../chunk-DYKUDQHN.js";import"../chunk-TU3JZGTL.js";import"../chunk-LIPHC4AO.js";export{b as IseResponse,a as IseResponseDataStatus}; |
{ | ||
"name": "xfyun-client", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "", | ||
@@ -40,3 +40,3 @@ "author": "Arumi Sakura", | ||
"ts-node": "^10.9.1", | ||
"tsup": "^6.7.0", | ||
"tsup": "^8.0.2", | ||
"typescript": "5.1" | ||
@@ -43,0 +43,0 @@ }, |
@@ -30,2 +30,7 @@ import { BehaviorSubject, concatMap, delay, delayWhen, filter, finalize, firstValueFrom, Observable, of, Subject } from 'rxjs'; | ||
/** | ||
* Messages to send to WebSocket | ||
*/ | ||
protected $message = new Subject<string>(); | ||
protected Option(): O { | ||
@@ -43,3 +48,2 @@ return new ApiOption() as O; | ||
this.$chunked = this.$audio.pipe( | ||
delayWhen(() => this.$status.pipe(filter((status) => status === ApiConnectionStatus.ready || status === ApiConnectionStatus.ing))), | ||
splitInChunks(chuckLength), | ||
@@ -51,2 +55,10 @@ concatMap((x) => of(x).pipe(delay(chuckDelay))), | ||
this.$chunked.subscribe((buffer) => this.sendAudio(buffer)); | ||
this.$message | ||
.pipe( | ||
delayWhen(() => this.$status.pipe(filter((status) => status === ApiConnectionStatus.ready || status === ApiConnectionStatus.ing))), | ||
) | ||
.subscribe((message) => { | ||
this.webSocket.send(message); | ||
}); | ||
} | ||
@@ -97,5 +109,11 @@ | ||
return Promise.resolve(); | ||
return await Promise.resolve(); | ||
} | ||
async send16BitPCMBuffer(buffer: Uint8Array): Promise<void> { | ||
this.$audio.next(buffer); | ||
return await Promise.resolve(); | ||
} | ||
async complete(): Promise<Res> { | ||
@@ -174,3 +192,3 @@ this.$audio.complete(); | ||
protected sendRequest(request: Req): void { | ||
this.webSocket.send(JSON.stringify(request)); | ||
this.$message.next(JSON.stringify(request)); | ||
} | ||
@@ -177,0 +195,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
104896
161
1518