Skip to content

Commit

Permalink
feat: 添加语音合成speak方法的utteranceId参数
Browse files Browse the repository at this point in the history
  • Loading branch information
gdoudeng committed Mar 22, 2024
1 parent 0762a26 commit f73d4f3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/BaiduSynthesizer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmitterSubscription, NativeEventEmitter, NativeModules } from 'react-native';
import { EventName, ITtsOptions, SynthesizerData, SynthesizerResultData, SynthesizerResultError } from './types';
import { EmitterSubscription, NativeEventEmitter, NativeModules } from "react-native";
import { EventName, ITtsOptions, SynthesizerData, SynthesizerResultData, SynthesizerResultError } from "./types";

const BaiduSynthesizerModule = NativeModules.BaiduSynthesizerModule;
const eventEmitter = new NativeEventEmitter(BaiduSynthesizerModule);
Expand Down Expand Up @@ -37,7 +37,7 @@ export default class BaiduSynthesizer {
options?: ITtsOptions | ((status: number) => void),
callback?: (status: number) => void
): void {
if (typeof utteranceId === 'string') {
if (typeof utteranceId === "string") {
BaiduSynthesizerModule.speak(text, utteranceId, options as ITtsOptions, callback);
} else {
BaiduSynthesizerModule.speak(text, null, utteranceId as ITtsOptions, options as (status: number) => void);
Expand Down Expand Up @@ -99,11 +99,11 @@ export default class BaiduSynthesizer {
private static addListener(eventName: EventName, cb: (data: SynthesizerData) => void): EmitterSubscription {
return eventEmitter.addListener(eventName, (data: SynthesizerData<string | undefined>) => {
// java传过来的是字符串
if (data.code && typeof data.data === 'string' && data.data.startsWith('{')) {
if (data.code && typeof data.data === "string" && data.data.startsWith("{")) {
try {
data.data = JSON.parse(data.data);
} catch (e) {
console.log('BaiduSynthesizer.addListener JSON.parse error', e, data.data);
console.log("BaiduSynthesizer.addListener JSON.parse error", e, data.data);
}
}
cb(data);
Expand Down

0 comments on commit f73d4f3

Please sign in to comment.