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)