Error on transcript audio file

I’m trying to create an app in node.js for audio transcription.

npm init
npm install openai
npm install fs-extra 
npm install path 
touch index.js

A creat my Api on OpenAI Platform

The content of index.js

const fs = require('fs');
const path = require('path');
const { OpenAIAPI } = require('openai'); // Use a biblioteca real do OpenAI

const openai = new OpenAIAPI({ key: 'SUA_API_KEY' }); // Substitua 'SUA_API_KEY' pela sua chave de API do OpenAI

async function transcreverAudio(caminhoDoArquivo) {
  try {
    const audioStream = fs.createReadStream(caminhoDoArquivo);
    const { data } = await openai.createTranscription({
      audio: audioStream,
      model: 'whisper-1',

    console.log("Transcrição:", data.text);
    return data.text;
  } catch (error) {
    console.error("Erro durante a transcrição:", error.message);
    throw error;

// Substitua 'caminho/do/seu/arquivo.m4a' pelo caminho real do seu arquivo de áudio
const caminhoDoArquivo = path.join("C:", "Users", "Robison", "Downloads", "Music", "Reuniao_GATIC_30-10-23.m4a");

  .then(transcricao => {
    // Faça algo com a transcrição, como enviar para o usuário no chat.
    console.log("Transcrição completa:", transcricao);
  .catch(err => {
    // Lide com erros aqui
    console.error("Erro geral:", err);

After running index.js it shows:

$ node wisper.js 
    constructor({ apiKey = Core.readEnv('OPENAI_API_KEY'), organization = Core.readEnv('OPENAI_ORG_ID') ?? null, ...opts } = {}) {

SyntaxError: Unexpected token ?
    at new Script (vm.js:83:7)
    at createScript (vm.js:267:10)
    at Object.runInThisContext (vm.js:319:10)
    at Module._compile (internal/modules/cjs/loader.js:685:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:22:18)

Could you help me?

[ ]’ Robison

Hi and welcome to the Developer Forum!

Try updating your Node.js version to 16 or higher, 18 would be preferable.

The ?? operator is not present in earlier versions.