0

I'm using python with anaconda.

AttributeError: module 'pydub' has no attribute 'playback'

I get the error above when I try to run the following statement:

speech = pydub.AudioSegment.from_mp3("temp_speak.mp3")

pydub.playback.play(speech)

the problem is , I can see there is a module called playback in the auto completition of visual studio code , besides that , when I get to the

~/anaconda3/envs/env_name/lib/python3.7/site-packages/pydub

I can see that there is a file named playback and its not corrupted.

here is the output of ls :

audio_segment.py generators.py playback.py scipy_effects.py effects.py __init__.py pyaudioop.py silence.py exceptions.py logging_utils.py __pycache__ utils.py

And I'm sure that I'm activating the environment before I run my script.

Ruinas
  • 1
  • 1
  • Unfamiliar with `pydub`, but I would expect the proper syntax to look like `speech.play()` – tripleee Nov 10 '20 at 07:51
  • speech just gets the audio segment and saves it on a variable. In pydub , you play the audio segments with the playback module. Thanks for the answer anyways. – Ruinas Nov 11 '20 at 05:13

1 Answers1

0

I solved the problem by importing the playback module serperately. Still can not understand why the interpreter thinks playback module is an attribute.

Ruinas
  • 1
  • 1