-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #178 from iceljc/features/refine-chat-window
Features/refine chat window
- Loading branch information
Showing
20 changed files
with
1,291 additions
and
759 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<script> | ||
import { initSpeech, stopAll } from "$lib/common/audio-player/store"; | ||
import { onMount } from "svelte"; | ||
/** @type {string} */ | ||
export let text; | ||
/** @type {boolean} */ | ||
export let mutex = true; | ||
/** @type {string} */ | ||
export let containerClasses = ""; | ||
/** @type {string} */ | ||
export let containerStyles = ""; | ||
/** @type {boolean} */ | ||
export let disableDefaultStyles = false; | ||
/** @type {boolean} */ | ||
let speaking = false; | ||
/** @type {import('$types').SpeechModel} */ | ||
let speech; | ||
onMount(() => { | ||
speech = { | ||
synth: window?.speechSynthesis, | ||
utterThis: new SpeechSynthesisUtterance(), | ||
stop: () => stop() | ||
}; | ||
initSpeech(speech); | ||
}); | ||
/** @param {string} transcript */ | ||
function utter(transcript) { | ||
if (mutex) { | ||
stopAll(); | ||
} | ||
speaking = true; | ||
speech.utterThis.text = transcript; | ||
speech.synth.speak(speech.utterThis); | ||
} | ||
function speak() { | ||
speaking = !speaking; | ||
if (speaking) { | ||
utter(text); | ||
} else { | ||
speech.synth.cancel(); | ||
} | ||
} | ||
const stop = () => { | ||
speaking = false; | ||
if (speech?.synth) { | ||
speech.synth.cancel(); | ||
} | ||
} | ||
</script> | ||
<!-- svelte-ignore a11y-click-events-have-key-events --> | ||
<!-- svelte-ignore a11y-no-static-element-interactions --> | ||
<div | ||
class="{disableDefaultStyles ? '' : 'chat-speaker-container'} {containerClasses}" | ||
style={`${containerStyles}`} | ||
on:click={() => speak()} | ||
> | ||
{#if !speaking} | ||
<span> | ||
<i class="bx bx-volume" /> | ||
</span> | ||
{:else} | ||
<span> | ||
<i class="bx bx-volume-full" /> | ||
</span> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.