سؤال

أحاول قراءة ملف *.wav باستخدام Scipy. أفعل ما يلي:

import scipy
x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')

نتيجة لهذا الرمز أحصل عليه:

Traceback (most recent call last):
  File "test3.py", line 2, in <module>
    x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')
AttributeError: 'module' object has no attribute 'io'

هل يعرف أي شخص ما هو الخطأ هنا؟ شكرا لكم مقدما.

هل كانت مفيدة؟

المحلول

كما يقول الخطأ ، لا تحتوي وحدة Scipy على "IO".

io.wavfile هي وحدة فرعية ، تحتاج إلى ذلك from scipy.io import wavfile ثم افعل wavfile.read("/usr/share/sounds/purple/receive.wav")

هذا يعطيني خطأ في الملف الذي تستخدمه كمثال ، ولكن ...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top