Skip to content

nodejs 基础对话

bash
npm i openai
js
const fs = require('fs');
const OpenAI = require('openai');

const openai = new OpenAI({
  apiKey: 'sk-xxxxxxxx', 
  baseURL: 'https://api.wlai.vip/v1'
});

async function transcribeAudio() {
  try {
    const transcription = await openai.audio.transcriptions.create({
      file: fs.createReadStream('a-product-demo-167264.mp3'), // 替换为你的音频文件路径
      model: 'whisper-1', 
    });

    console.log('转录结果:', transcription.text);
  } catch (error) {
    console.error('转录出错:', error);
  }
}

transcribeAudio();

AnyAPI — 专业的 AI 接口聚合服务