Skip to content

Commit

Permalink
Merge pull request #98 from n4ze3m/next
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
n4ze3m authored May 25, 2024
2 parents 0e29354 + d5f7d0a commit 3868048
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"react-i18next": "^14.1.0",
"react-markdown": "8.0.0",
"react-router-dom": "6.10.0",
"react-speech-recognition": "^3.10.0",
"react-syntax-highlighter": "^15.5.0",
"react-toastify": "^10.0.4",
"rehype-mathjax": "4.0.3",
Expand Down
18 changes: 9 additions & 9 deletions src/components/Option/Playground/PlaygroundForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { ImageIcon, MicIcon, StopCircleIcon, X } from "lucide-react"
import { getVariable } from "~/utils/select-varaible"
import { useTranslation } from "react-i18next"
import { KnowledgeSelect } from "../Knowledge/KnowledgeSelect"
import { useSpeechRecognition } from "react-speech-recognition"
import SpeechRecognition from "react-speech-recognition"
import { useSpeechRecognition } from "@/hooks/useSpeechRecognition"

type Props = {
dropedFile: File | undefined
Expand Down Expand Up @@ -86,11 +85,12 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {

const {
transcript,
listening: isListening,
isListening,
resetTranscript,
browserSupportsSpeechRecognition
start: startListening,
stop: stopSpeechRecognition,
supported: browserSupportsSpeechRecognition
} = useSpeechRecognition()

const { sendWhenEnter, setSendWhenEnter } = useWebUI()

React.useEffect(() => {
Expand Down Expand Up @@ -169,7 +169,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {

const stopListening = async () => {
if (isListening) {
SpeechRecognition.stopListening()
stopSpeechRecognition()
}
}

Expand Down Expand Up @@ -281,12 +281,12 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
type="button"
onClick={async () => {
if (isListening) {
SpeechRecognition.stopListening()
stopSpeechRecognition()
} else {
resetTranscript()
SpeechRecognition.startListening({
startListening({
continuous: true,
language: speechToTextLanguage
lang: speechToTextLanguage
})
}
}}
Expand Down
21 changes: 10 additions & 11 deletions src/components/Sidepanel/Chat/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { defaultEmbeddingModelForRag } from "~/services/ollama"
import { ImageIcon, MicIcon, StopCircleIcon, X } from "lucide-react"
import { useTranslation } from "react-i18next"
import { ModelSelect } from "@/components/Common/ModelSelect"
import { useSpeechRecognition } from "react-speech-recognition"
import SpeechRecognition from "react-speech-recognition"
import { useSpeechRecognition } from "@/hooks/useSpeechRecognition"

type Props = {
dropedFile: File | undefined
Expand All @@ -32,16 +31,16 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
})
const {
transcript,
listening: isListening,
isListening,
resetTranscript,
browserSupportsSpeechRecognition
} = useSpeechRecognition({

})
start: startListening,
stop: stopSpeechRecognition,
supported: browserSupportsSpeechRecognition
} = useSpeechRecognition()

const stopListening = async () => {
if (isListening) {
SpeechRecognition.stopListening()
stopSpeechRecognition()
}
}

Expand Down Expand Up @@ -218,12 +217,12 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
type="button"
onClick={async () => {
if (isListening) {
SpeechRecognition.stopListening()
stopListening()
} else {
resetTranscript()
SpeechRecognition.startListening({
startListening({
continuous: true,
language: speechToTextLanguage
lang: speechToTextLanguage
})
}
}}
Expand Down
8 changes: 7 additions & 1 deletion src/hooks/useSpeechRecognition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type SpeechRecognitionHook = {
stop: () => void
supported: boolean
transcript: string
resetTranscript: () => void
}

const useEventCallback = <T extends (...args: any[]) => any>(
Expand Down Expand Up @@ -88,6 +89,10 @@ export const useSpeechRecognition = (
}
}, [])

const resetTranscript = () => {
setLiveTranscript("")
}

const processResult = (event: SpeechRecognitionEvent) => {
const transcript = Array.from(event.results)
.map((result) => result[0])
Expand Down Expand Up @@ -167,6 +172,7 @@ export const useSpeechRecognition = (
isListening: listening,
stop,
supported,
transcript: liveTranscript
transcript: liveTranscript,
resetTranscript
}
}
8 changes: 4 additions & 4 deletions wxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default defineConfig({
outDir: "build",

manifest: {
version: "1.1.9",
version: "1.1.10",
name:
process.env.TARGET === "firefox"
? "Page Assist - A Web UI for Local AI Models"
Expand All @@ -60,10 +60,10 @@ export default defineConfig({
browser_specific_settings:
process.env.TARGET === "firefox"
? {
gecko: {
id: "page-assist@nazeem"
}
gecko: {
id: "page-assist@nazeem"
}
}
: undefined,
host_permissions:
process.env.TARGET !== "firefox"
Expand Down

0 comments on commit 3868048

Please sign in to comment.