Skip to content

Commit

Permalink
fix: 切换角色时语音播放异常
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxinqi committed Apr 26, 2023
1 parent 73d13dd commit ae7dc9e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/hooks/useSpeechService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const useSpeechService = ({ langs = <const>['fr-FR', 'ja-JP', 'en-US', 'z
speechConfig.value.speechSynthesisLanguage = lang
speechConfig.value.speechSynthesisVoiceName = voice
console.log(lang, voice)

// 通过playback结束事件来判断播放结束
const player = new SpeakerAudioDestination()
player.onAudioStart = function (_) {
Expand Down
1 change: 1 addition & 0 deletions src/pages/Home/components/Content.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ useEventListener(document, 'keyup', async (e) => {
// effects
watch(messageLength, () => nextTick(() => scrollToBottom()))
watch(currentKey, () => {
isPlaying.value = false
language.value = currentLanguage.value as any
voiceName.value = currentVoice.value
rate.value = currentRate.value
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/components/NewChat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const selectVoiceName = ref('')
const desc = ref('')
const name = ref('')
const rate = ref('1.0')
const previewText = ref('hello wrold')
const previewText = ref('polyglot is awesome!')
const canAdd = computed(() => !!(selectLanguage.value && selectVoiceName.value && desc.value && name.value))
Expand Down

0 comments on commit ae7dc9e

Please sign in to comment.