Tensorflow speech commands use local files instead of HTTP request for speechCommands.create()

28 Views Asked by At

I am making a project using a machine learning model I trained using Google Teachable machine. I downloaded the files that teachable machine produced (model.json, metadata.json, and weights.bin). The are in a directory called model.

My problem is that the metadata URL is not working. I get the errorspeech-commands.min.js:17 Uncaught (in promise) Error: Unsupported URL scheme in metadata URL: ./model/metadata.json. Supported schemes are: http://, https://, and (node.js-only) file://. Is there a way I can use speechCommands.create() with a local link and not https request?

Here is my code:

  
   
    async function createModel() {
        const checkpointURL = "./model/model.json"; // model topology
        const metadataURL = "./model/metadata.json"; // model metadata

        const recognizer = speechCommands.create(
            "BROWSER_FFT", // fourier transform type, not useful to change
            undefined, 
            checkpointURL,
            metadataURL);

        // check that model and metadata are loaded via HTTPS requests.
        await recognizer.ensureModelLoaded();

        return recognizer;
    }


These are the libraries I have imported as recommended by teachable machine:

  <script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]/dist/speech-commands.min.js"></script>
  

This is my first time asking a question here. If I can improve it in any way, please let me know! Thank you for any help!

0

There are 0 best solutions below