ModuleNotFoundError: No module named 'azure' ___ (but the required module "azure-cognitiveservices-speech" is already in requirements.txt)

Summary

I’m trying to build a Streamlit app that leverages the Azure Speech API for speech-to-text and text-to-speech tasks.

The functionality in the backend works as intended, but when I try to add the Streamlit frontend, I get an exception:

ModuleNotFoundError: No module named ‘azure’

I’ve explored threads related to similar problems, and I see that the solution should be to include the module in the requirements.txt file.

In my case, I’ve already included the correct module there (azure-cognitiveservices-speech). Nevertheless, it seems that Streamlit is asking to import the full “azure”, rather than only the specific service I need. Is this a bug, or the intended behavior?

requirements.txt

When I test the functionality without using Streamlit, the system works as expected:

  1. When I speak on the microphone, the audio signal is recognised
  2. The system is also able to synthesise the text, as expected

When I try to embed these functions in a Streamlit app, on the contrary, the system raises this exception:

Hey @andreaxricci,

Can you share your GitHub repo so we can fork it and try to reproduce this error/find a solution?

Thanks for the reply, Caroline.
When recreating a new virtual environment from scratch, the error disappeared. I had alternated between Streamlit and Flask… maybe something hadn’t run correctly during the make install.
No further support needed on this topic.
Best Regards,
Andrea

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.