How to Set Up Speech-to-Text in Notion Using Whisper AI Without Errors?

This topic was automatically generated from Slack. You can find the original thread here.

Have been trying to set up speech to text in Notion using whisper ai.
https://thomasjfrank.com/how-to-transcribe-audio-to-text-with-chatgpt-and-notion/#codeheavy

It is throwing me an error. I do not know what to do. Can someone please help

Did you happen to see this section of Thomas’ article? He outlined a few common issues and solution there. Please check there if you don’t mind and let me know if that helps.

If it doesn’t help, please share the error you’re seeing and a screenshot / logs with any detail.

thank you for being so prompt! I did . My issue is not mentioned there.

In this step I m getting the error ‘ "Failed to read audio file metadata. The file format might be unsupported or corrupted, or the file might no longer exist at the specified file path (which is in temp storage)

A common problem I’ve been seeing is the **const** filePath = steps.download_file_to_tmp.$return_value.tmpPath doesn’t match the tmpPath: in the download_file_to_tmp step.

If you copy the path, it should match the the const filePath.

I am confused. can you rectify this code please?

import { parseFile } from ‘music-metadata’;
import { inspect } from ‘util’;

export default defineComponent({
async run({ steps, $ }) {

try {
  // Get the tmp file path
  const filePath = steps.Download_to_tmp.$return_value.tmpPath

  if (!filePath) {
    throw new Error("File path is missing or invalid.");
  }

  // Parse the file with music-metadata
  let dataPack;
  try {
    dataPack = await parseFile(filePath);
  } catch (error) {
    throw new Error("Failed to read audio file metadata. The file format might be unsupported or corrupted, or the file might no longer exist at the specified file path (which is in temp storage).");
  }

  // Get and return the duration in seconds
  const duration = Math.round(await inspect(dataPack.format.duration, { showHidden: false, depth: null }));
  return duration;
} catch (error) {
  // Log the error and return an error message or handle the error as required
  console.error(error);
  throw new Error(`An error occurred while processing the audio file: ${error.message}`);
}

},
})

do you have a step in your workflow named Download_to_tmp? Can you show a screenshot of the Exports section below that step?

There you go

Thanks. Please replace the code you shared above with this code:

import { parseFile } from 'music-metadata';
import { inspect } from 'util';
export default defineComponent({
  async run({ steps, $ }) {
    // Get the tmp file path
    const filePath = steps.Download_to_tmp.$return_value.tmpPath
    if (!filePath) {
      throw new Error("File path is missing or invalid.");
    }
    // Parse the file with music-metadata
    let dataPack;
    dataPack = await parseFile(filePath);
    // Get and return the duration in seconds
    const duration = Math.round(await inspect(dataPack.format.duration, { showHidden: false, depth: null }));
    return duration;
  },
})

then run it again. It may error. Let me know what the new error says, with the full data under Details

Ok. Let me try!!!

Unfortunately

Both steps here

Is there a possibility that the music-metadata library might not be functioning correctly?

Try to check the download_to_tmp step - it may not be successfully saving the m4a file there.

Got it! Will do. Thank you