refac: audio

This commit is contained in:
Timothy J. Baek 2024-06-07 20:55:50 -07:00
parent 27417dd771
commit c6b74a3cf9
2 changed files with 4 additions and 5 deletions

View File

@ -267,7 +267,7 @@
</div>
</div>
<div class="w-full">
<div class=" mb-2.5 text-sm font-medium">{$i18n.t('TTS Model')}</div>
<div class=" mb-1.5 text-sm font-medium">{$i18n.t('TTS Model')}</div>
<div class="flex w-full">
<div class="flex-1">
<input

View File

@ -1,7 +1,7 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import { createEventDispatcher, tick, getContext } from 'svelte';
import { settings } from '$lib/stores';
import { config, settings } from '$lib/stores';
import { blobToFile, calculateSHA256, findWordIndices } from '$lib/utils';
import { transcribeAudio } from '$lib/apis/audio';
@ -185,8 +185,7 @@
}
};
mediaRecorder.start();
if (($settings?.audio?.stt?.engine ?? '') === 'web') {
if ($config.audio.stt.engine === 'web' || ($settings?.audio?.stt?.engine ?? '') === 'web') {
if ('SpeechRecognition' in window || 'webkitSpeechRecognition' in window) {
// Create a SpeechRecognition object
speechRecognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
@ -195,7 +194,7 @@
speechRecognition.continuous = true;
// Set the timeout for turning off the recognition after inactivity (in milliseconds)
const inactivityTimeout = 3000; // 3 seconds
const inactivityTimeout = 2000; // 3 seconds
let timeoutId;
// Start recognition