save as json format from Web Speech API Transcript

I am using web speech recognition API in Chrome to get transcripts & store in a string array variable(called notes). I would like to save the full transcripts as json so I can easily use it later.

Currently my project has html, css & script.js, the transcripts are stored in localStorage. May I know how should I work to save the transcript as json? Or if there are any useful links?

I watched the related videos(
https://youtu.be/T7s3st6xfpA?t=205
), result.js will be created if i assign the info in a variable (notesInfo) & call

node saveFile.js

saveFile.js

  const notesInfo = {
      date:'1.12.2021', content:'How are you'
  }

  const fs = require('fs');

  const saveData = (notesInfo) => {
        const finished = (error) => {
            if(error){
              console.error(error)
              return;
            }
        }

        const jsonData = JSON.stringify(notesInfo)
        fs.writeFile('result.json', jsonData, finished)
  }

  saveData(notesInfo)

result.json

{"date":"1.12.2021","content":"How are you"}

But this is suitable for assigning a predictable data ({“date”:”1.12.2021″,”content”:”How are you”})into a variable (notesInfo). But I want my string array variable (notes) which generated from Web Speech Recognition can be saved in a new json file automatically when i start using speech Recognition in my web brower. I worked for days but still have no ideas.

Thank you for your kindness!