400 Bad request using whisper with AzureCliCredentials

Julien C 0 Reputation points

I'm trying to use Whisper using the AzureCliCredential and i always get an error as follow
{ code: 'Request is badly formated', message: 'Resource Id is badly formed: NA' }

my very simple code is :

import * as fs from "fs";
import { AzureCliCredential } from "@azure/identity";
import { OpenAIClient } from "@azure/openai";

const AZURE_SPEECH_ENDPOINT = "https://westeurope.api.cognitive.microsoft.com/";
const client = new OpenAIClient(AZURE_SPEECH_ENDPOINT, new AzureCliCredential());

const res = await client.getAudioTranscription("whisper", await fs.promises.readFile(`audio.m4a`));

it works perfectly I use the access key instead :

const client = new OpenAIClient(AZURE_SPEECH_ENDPOINT, new AzureKeyCredential("xxxxxx"));

I checked my role assignments on the resource and my account is assigned :

Cognitive Services Contributor
Cognitive Services OpenAI Contributor
Cognitive Services OpenAI User
Cognitive Services Speech Contributor
Cognitive Services Speech User
Cognitive Services User

I also checked that I am correctly logged on right tenant and subscription using az login.

What is the issue ?

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,475 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,441 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 18,735 Reputation points Microsoft Employee

    @Julien C Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    I was able to update your sample code and run it at my end on my resource.


    From your sample code, it seems like you are using a speech service endpoint and not Azure Open AI endpoint.


    Could you please confirm if you are passing a valid endpoint URI to an Azure OpenAI resource ?

    User's image

    Sample code here.

    Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.

    0 comments No comments