Librosa libray [Python] resample function on Azure Function

Wang Zihao 11 Reputation points
2021-11-13T10:24:06.54+00:00

I am using librosa to resample the audio data, like below:

import librosa
filename = "/home/.../example.mp3"
audio, original_samplerate = librosa.load(filename) 
target_samplerate = 24000
new_audio = librosa.resample(audio,original_samplerate ,target_samplerate ,res_type='sinc_fastest')

This code works in my local linux system. However, when I deploy such code to the Azure function, it outputs Error: OSError: sndfile library not found Stack

The reason should be the librosa.resample function needs two C build Libs: Libsndfile and Libsamplerate. I can install them on my local linux system:

For Libsndfile:

sudo apt-get libsndfile1
sudo apt-get libsndfile-dev

For Libsamplerate: I first download the file from github: https://github.com/libsndfile/libsamplerate
Then just follow the install instruction:

./configure
make
make check
make install

But how to install these two Libs on Azure function?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MikeUrnun 9,777 Reputation points Moderator
    2021-11-15T21:47:39.637+00:00

    Hello @Wang Zihao - It looks like the same question was answered on Stackoverflow: https://stackoverflow.com/questions/64839406/using-librosa-in-an-azure-function-app-written-in-python

    You might also review our new Container Apps offering as well: https://azure.microsoft.com/en-us/services/container-apps/#overview


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.