jhubbardsf / svelte-speech-recognition

Speech recognition library for Svelte
https://svelte-speech-recognition.netlify.app/
30 stars 5 forks source link

Basic example not working #1

Open juanjo opened 2 years ago

juanjo commented 2 years ago

I have just followed the basic example and this is what I get:

Failed to resolve entry for package "svelte-speech-recognition". The package may have incorrect main/module/exports specified in its package.json: Missing "." export in "svelte-speech-recognition" package

bhvngt commented 2 years ago

I am facing similar issues. I worked around this by importing specific imports like svelte-speech-recognition/SpeechRecognition. After that when I run on dev mode, my sveltekit app starts throwing error

Watching for file changes...✘ [ERROR] Could not resolve "$app/env"
./node_modules/.pnpm/svelte-speech-recognition@0.0.5/node_modules/svelte-speech-recognition/SpeechRecognition.js:3:24:
      3 │ import { browser } from '$app/env';
        ╵                         ~~~~~~~~~~

Since this is supposed to be called only in the browser, I am importing this module inside my onMount method like this

onMount(async () => {
  const { useSpeechRecognition } = await import("svelte-speech-recognition/SpeechRecognition");
  const { browserSupportsSpeechRecognition } = useSpeechRecognition({transcribing: true, clearTranscriptOnListen: null, commands: null});
  console.log(`browserSupportsSpeechRecognition`, browserSupportsSpeechRecognition);
}
jhubbardsf commented 2 years ago

Hey guys, sorry for not getting back sooner. Thank you both for bringing this my attention. In the process of fixing both issues.

I'm looking into the SSR issues as well. In the example app in this repository it works fine outside of onMount. Trying to figure out why SSR breaks it while importing from the npm library.

I'll have more time to look at it this week and update/fix these issues.

Gildedter commented 3 months ago

having the same issue, I'm using sveltejs v3 bootstrapped to a codeigniter project