0

I'm quite new to python and I've been working on a simple program that would record sound, modify it a bit and then playback it. I wrote it in Visual Studio but this software won't work for me with sounddevice and says No module named '_sounddevice_data' but when I run it with python "path to this file" in Anaconda Prompt it works without any problem. This package is in Visual's python environment which I use- Anaconda 5.2.0. On the other hand, running from Anaconda Prompt won't work with tensorflow due to some error which is skipped in Visual Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2. What's more, everything works great when I use simple .bat file to run this code :D

echo off

CALL  D:\Users\blaze\Anaconda3\Scripts\activate.bat D:\Users\blaze\Anaconda3
python C:\Users\blaze\source\repos\recorder\recorder\recorder.py

echo on 

I'd be grateful for any help because I just can't understand what is going on. Here's the code:

import tensorflow as  tf
import numpy as np
import time
import glob
import os
model=tf.keras.models.load_model("D:\Projekt\ML\save\model.h5py",compile=True)

duration = 100  # seconds
frames = 8192
global a 
a=0

file_list_c = glob.glob(os.path.join(os.getcwd(), "Check", "*.txt"))
for file_path in file_list_c:
    with open(file_path) as f:       
        datax =np.genfromtxt(file_path)     
        datax=np.reshape(datax,(-1,8192))
        print(model.predict(datax))
        print(np.argmax(model.predict(datax)))

import sounddevice as sd
def callback(indata, outdata, frames, time, status):
    if status:
        print(status)
    print(np.argmax(model.predict(np.reshape(indata,(-1,8192)))))
    outdata[:] = indata


with sd.Stream(samplerate=48000,blocksize=8192,channels=1, callback=callback):
    sd.sleep(int(duration*1000))


time.sleep(100)
  • Please specify how exactly you installed the `sounddevice` module. – Matthias Feb 26 '19 at 09:08
  • This is not an actual error: `Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2`. It is just a warning that tells you that your CPU could do the calculations even faster if you would compile TensorFlow with appropriate settings. But it should still work correctly, just a little (or not so little?) bit slower. – Matthias Feb 26 '19 at 09:12
  • Hi @Matthias, I installed the module by typing `conda install -c conda-forge python-sounddevice` in Anaconda Prompt and it can be seen in python environment- https://www.dropbox.com/s/mapk0xr6dsst75h/iten.png?dl=0 Actually, tensorflow accesed from Anaconda Command Prompt has some other errors too which look like that https://www.dropbox.com/s/c9pfbjv5taohgcm/ten.png?dl=0 – Błażej Smorawski Feb 26 '19 at 17:14
  • Hmmm, I don't know what's going wrong when you launch the script from Visual Studio. As a work-around, you could try to install the `sounddevice` module with `pip` instead of `conda` (un-installing it with `conda` first). – Matthias Feb 27 '19 at 08:23
  • I don't know too much about lunching .py in Visual Studio, so I can't say anyhing but maybe you know something about using .bat? This way everything is working good, so maybe problem is in Anaconda Command Prompt? – Błażej Smorawski Feb 28 '19 at 13:25
  • Sorry, I don't know. I'm neither a Windows nor an Anaconda user. – Matthias Feb 28 '19 at 17:24

0 Answers0