mirror of
https://github.com/idootop/mi-gpt.git
synced 2024-09-20 06:45:38 +00:00
fix: 变量名统一使用小驼峰
This commit is contained in:
parent
f7cf78f7ea
commit
359a61edcb
|
@ -70,11 +70,11 @@ class _BotConfig {
|
|||
private _logger = Logger.create({ tag: "BotConfig" });
|
||||
private botIndex?: IBotIndex;
|
||||
|
||||
private _index_path = ".bot.json";
|
||||
private _indexPath = ".bot.json";
|
||||
|
||||
private async _getIndex(): Promise<IBotIndex | undefined> {
|
||||
if (!this.botIndex) {
|
||||
this.botIndex = await readJSON(this._index_path);
|
||||
this.botIndex = await readJSON(this._indexPath);
|
||||
}
|
||||
return this.botIndex;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ class _BotConfig {
|
|||
botId: bot.id,
|
||||
masterId: master.id,
|
||||
};
|
||||
await writeJSON(this._index_path, this.botIndex);
|
||||
await writeJSON(this._indexPath, this.botIndex);
|
||||
}
|
||||
const bot = await UserCRUD.get(this.botIndex!.botId);
|
||||
if (!bot) {
|
||||
|
|
|
@ -49,7 +49,7 @@ export type BaseSpeakerConfig = MiServiceConfig & {
|
|||
/**
|
||||
* TTS 开始/结束提示音
|
||||
*/
|
||||
audio_beep?: string;
|
||||
audioBeep?: string;
|
||||
};
|
||||
|
||||
export class BaseSpeaker {
|
||||
|
@ -69,9 +69,9 @@ export class BaseSpeaker {
|
|||
tts = "xiaoai",
|
||||
ttsCommand = [5, 1],
|
||||
wakeUpCommand = [5, 3],
|
||||
audio_beep = process.env.AUDIO_BEEP,
|
||||
audioBeep = process.env.audioBeep,
|
||||
} = config;
|
||||
this.audio_beep = audio_beep;
|
||||
this.audioBeep = audioBeep;
|
||||
this.interval = interval;
|
||||
this.tts = tts;
|
||||
this.ttsCommand = ttsCommand;
|
||||
|
@ -94,7 +94,7 @@ export class BaseSpeaker {
|
|||
await this.MiIOT!.doAction(...this.ttsCommand, kAreYouOK);
|
||||
}
|
||||
|
||||
audio_beep?: string;
|
||||
audioBeep?: string;
|
||||
responding = false;
|
||||
async response(options: {
|
||||
tts?: TTSProvider;
|
||||
|
@ -138,7 +138,7 @@ export class BaseSpeaker {
|
|||
if (_response.length < 1) {
|
||||
// 播放开始提示音
|
||||
if (playSFX) {
|
||||
await this.MiNA!.play({ url: this.audio_beep });
|
||||
await this.MiNA!.play({ url: this.audioBeep });
|
||||
}
|
||||
// 在播放 TTS 语音之前,先取消小爱音箱的唤醒状态,防止将 TTS 语音识别成用户指令
|
||||
if (ttsNotXiaoai) {
|
||||
|
@ -162,7 +162,7 @@ export class BaseSpeaker {
|
|||
if (_response.length > 0) {
|
||||
// 播放结束提示音
|
||||
if (playSFX) {
|
||||
await this.MiNA!.play({ url: this.audio_beep });
|
||||
await this.MiNA!.play({ url: this.audioBeep });
|
||||
}
|
||||
}
|
||||
// 保持唤醒状态
|
||||
|
@ -208,7 +208,7 @@ export class BaseSpeaker {
|
|||
const play = async (args?: { tts?: string; url?: string }) => {
|
||||
// 播放开始提示音
|
||||
if (playSFX) {
|
||||
await this.MiNA!.play({ url: this.audio_beep });
|
||||
await this.MiNA!.play({ url: this.audioBeep });
|
||||
}
|
||||
// 在播放 TTS 语音之前,先取消小爱音箱的唤醒状态,防止将 TTS 语音识别成用户指令
|
||||
if (ttsNotXiaoai) {
|
||||
|
@ -237,7 +237,7 @@ export class BaseSpeaker {
|
|||
}
|
||||
// 播放结束提示音
|
||||
if (playSFX) {
|
||||
await this.MiNA!.play({ url: this.audio_beep });
|
||||
await this.MiNA!.play({ url: this.audioBeep });
|
||||
}
|
||||
// 保持唤醒状态
|
||||
if (keepAlive) {
|
||||
|
|
|
@ -42,7 +42,7 @@ export type SpeakerConfig = BaseSpeakerConfig & {
|
|||
/**
|
||||
* 静音音频链接
|
||||
*/
|
||||
audio_silent?: string;
|
||||
audioSilent?: string;
|
||||
};
|
||||
|
||||
export class Speaker extends BaseSpeaker {
|
||||
|
@ -55,9 +55,9 @@ export class Speaker extends BaseSpeaker {
|
|||
const {
|
||||
heartbeat = 1000,
|
||||
exitKeepAliveAfter = 30,
|
||||
audio_silent = process.env.AUDIO_SILENT,
|
||||
audioSilent = process.env.audioSilent,
|
||||
} = config;
|
||||
this.audio_silent = audio_silent;
|
||||
this.audioSilent = audioSilent;
|
||||
this._commands = config.commands ?? [];
|
||||
this.heartbeat = heartbeat;
|
||||
this.exitKeepAliveAfter = exitKeepAliveAfter;
|
||||
|
@ -88,7 +88,7 @@ export class Speaker extends BaseSpeaker {
|
|||
}
|
||||
}
|
||||
|
||||
audio_silent?: string;
|
||||
audioSilent?: string;
|
||||
async activeKeepAliveMode() {
|
||||
while (this.status === "running") {
|
||||
if (this.keepAlive) {
|
||||
|
@ -96,7 +96,7 @@ export class Speaker extends BaseSpeaker {
|
|||
if (!this.responding) {
|
||||
// 没有回复时,一直播放静音音频使小爱闭嘴
|
||||
await this.MiNA?.play(
|
||||
this.audio_silent ? { url: this.audio_silent } : { tts: kAreYouOK }
|
||||
this.audioSilent ? { url: this.audioSilent } : { tts: kAreYouOK }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user