python – Azure long audio API – NodeJS

I am trying to make a post request to Azure speech services API to convert text to speech. The thing is that I am building a NodeJS backend and the documentation is only in Python.

What would be the JavaScript equivalent for this Python code? (I am using node-fetch)

    header = {
        'Ocp-Apim-Subscription-Key': 'some-key'
    payload = {
        'displayname': 'long audio synthesis sample',
        'description': 'sample description',
        'locale': 'en-US,
        'voices': [{ 'voicename': 'some-voice' }],
        'outputformat': 'riff-16khz-16bit-mono-pcm',
        'concatenateresult': True,

    filename = ntpath.basename('files/some-path')
    files = {
        'script': (filename, open('files/some-path', 'rb'), 'text/plain')

    response =, payload, headers=header, files=files)

Read more here: Source link