this is may problem.
I can load the audio_binary like this
audio_binary = tf.read_file(wav_file_path)
but when I try to read the wav with this:
from tensorflow.contrib import ffmpeg
waveform = ffmpeg.decode_audio( audio_binary, file_format='wav', samples_per_second=16000, channel_count=1)
I get error ImportError: No module named 'tensorflow.contrib.ffmpeg.ops'
I have also tried doing this:
from tensorflow.contrib.framework.python.ops import audio_ops as contrib_audio
wav_decoder = contrib_audio.decode_wav(audio_binary, desired_channels=1)
and I get this error InvalidArgumentError: Header mismatch: Expected RIFF but found NIST
By the way I'm using tensorflow-gpu in a Jupyter notebook.
Any help would be highly appreciated.
Thanks!
You might want to check what version of tensorflow you currently have.
tensorflow 1.X:
tensorflow.contrib.ffmpeg.decode_audio()
tensorflow 2.X:
tensorflow.audio.decode_wav()
keep in mind that decode_wav() needs the .wav data and cannot read it from the .wav data on it's own
for more information on tensorflow.audio.decode_wav() see documentation here: https://www.tensorflow.org/api_docs/python/tf/audio/decode_wav
check out this answer for more information: From audio to tensor, back to audio in tensorflow
In case someone has the same problem.
I was using TIMIT database, and their files, althought their were .wav, the have a differnet codification (NIST). I have to change them to RIFF, like this forfiles /s /m *.wav /c "cmd /c sph2pipe -f wav #file #fnameRIFF.wav"
and the use the second command contrib_audio.decode_wav(...)
Based on this answer:
Change huge amount of data from NIST to RIFF wav file
And this page:
http://soundfile.sapp.org/doc/WaveFormat/
Related
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\dnn\src\darknet\darknet_io.cpp:677: error: (-212:Parsing error) Unknown layer type: in function 'cv::dnn::darknet::ReadDarknetFromCfgStream
Code:
import cv2
import numpy as np
# Load Yolo
path =r"D:\yolov3-coco"
weight = path+r"\yolov3.weights"
cfg = path+r"\yolov3.cfg"
net = cv2.dnn.readNetFromDarknet(weight ,cfg )
classes = []
with open(path+"\coco.txt", "r") as f:
classes = [line.strip() for line in f.readlines()]
print(cfg)
print(weight)
print(classes)
cv2.destroyAllWindows()
I have already used the command net= cv2.dnn.readNet(weights,cfg) but it did not work i have also gone to https://pjreddie.com/media/files/yolov3.weights and downloaded the weights and config files and have put them in a folder called yolov3-coco.
You seem to be passing *.weights first and *.cfg later. If takes *.cfg first, then the darknet weights file. Reference for readNetFromDarknet,
https://docs.opencv.org/master/d6/d0f/group__dnn.html#gafde362956af949cce087f3f25c6aff0d
This problem is similar to,
YOLO V3 Video Stream Object Detection
Maybe yolo3-coco cfg and weight do not match so Unknown layer type error.
Path for yolov3.weights,yolov3.cfg is not proper so you can pass path directly where they are stored
net = cv.dnn.readNetFromDarknet("yolov3-coco/yolov3.cfg", "yolov3-coco/yolov3.weights")
For me it were the wrong files. I was trying it in google colab with version 2.5.0 of tensorflow. The following files worked:
!wget "https://pjreddie.com/media/files/yolov3.weights"
!wget "https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3.cfg"
!wget "https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names"
try to use OpenCV --version 5. My error was solved with this.
ı had trouble problem like this. Just check your code path and make sure where cfg,weights are,open main folder and work under the main folder.
I've downloaded a bunch of .krn files, and I'd like to convert them into images - either pngs or jpgs - using music21. I've tried this:
When I do this:
from music21 import *
op = krnfile
s = converter.parse(op)
s.show()
I see a great image file in the Jupyter Notebook I'm using, but when I try to save that file programatically like this:
s.write(fp = 'outputfile.png', fmt = 'png')
It says:
Music21ObjectException: cannot support showing in this format yet: png
Which seems a little weird since it obviously manages to make an image for display in the notebook.
It looks like maybe I could use LilypondConverter.createPNG(fileName=None) from this, but is installing Lilypond required? I already have MuseScore2 installed, which opens when I call s.show().
Thanks a lot!
Alex
Install musescore on your computer, re-run python -m music21.configure to help it find it and then do:
from music21 import *
op = 'krnfile.krn'
s = converter.parse(op)
fp = s.write('musicxml.png')
# or just s.show('musicxml.png') to test that it works.
If it's a multi-page file, fp will be the path to the first page. It will end in -1 or -01 or -001 etc. You can read through the directory to find other files with the same name until there are no more to get all the images.
If you use n.show('lily.png'), it should create a temporary png file somewhere. Try to use it and an image may open.
Sorry i don't know much yet, I hope it helps.
I can read all the *.dcm files from "imgs" with this command
vol = imageio.volread("imgs")
but I can't read jpg files. My image files has *.bmp.jpg extension (e.g. C001_IMG00023.bmp.jpg) and
histology = imageio.volread("imgs", "jpg")
command gave me
RuntimeError: Format JPEG-PIL cannot read in mode 'v'
then I read the docs and tried this command
histology = io.volread("imgs",mode="L", "jpg")
but it gave me this error
SyntaxError: positional argument follows keyword argument
I searched for the errors and about reading jpg files with imageio but i couldn't find anything about it. Is it possible to read image files from a folder with imageio or should I use different method for it? I want to read files with simple command like above.
You can always go for skimage,
from skimage.io import imread_collection
path= 'imgs/*.jpg'
histology=imread_collection(path)
I am trying to add simple text to a mp4 file. I have the mp4 file and I am using moviepy to add the text clip, however, I am continually running into errors.
My code:
import moviepy.editor as mpy
video_name='Test.mp4'
video = mpy.VideoFileClip('test_movie.mp4')
text = mpy.TextClip("Test", font="Arial", fontsize=40, color='white')
text = text.set_position('upper left').set_duration(video.duration)
test = mpy.CompositeVideoClip([video, text])
test.write_videofile('{}.mp4'.format(video_name))
And here is the error:
IOError: MoviePy Error: creation of None failed because of the following error:
convert: delegate library support not built-in '/Library/Fonts//Arial.ttf' (Freetype) # warning/annotate.c/RenderFreetype/1847.
convert: no decode delegate for this image format `PNG' # error/constitute.c/ReadImage/512.
convert: no images defined `PNG32:/var/folders/l3/m81nh88n57s9ck30_fqd09cmcfj06p/T/tmp06GxjE.png' # error/convert.c/ConvertImageCommand/3275.
.
.This error can be due to the fact that ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect
ImageMagick is installed on my system and I have been through a few threads on here but nothing has pointed me in the right direction. My font library is not empty and I do not know what it is having this issue. Any help would be greatly appreciated. I am on a Mac and using Spyder for a GUI.
Try to install ImageMagick from their website.
If the problem still there, find the moviepy/config_defaults.py and after the last line add:
IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick_VERSION\\convert.exe
It seems I need to use freeze_graph.py (unless I"m mistaken)
'https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/freeze_graph.py'
This is the graph I want to extract:
C:\tmp\output_graph.pb
I'm looking at freeze_graph.py but I"m having trouble understanding some of the
arguments of the script AND I'm ending in an import error.
--input_graph = the graph I want to extract.
--input_checkpoint ? I don't think I need this
--input binary I don't think I need this as my inputs were image file values
--output_node_names The labels?
----input_meta_graph not sure what this is.
I don't see an output argument for a text.file or pickle file that will
hold all weights.
I tried running the following line from command prompt:
python3.6 C:\Users\Moondra\tensorflow\tensorflow\python\tools\freeze_graph.py --input-graph=C:\tmp\output_graph.pb
However, I'm getting an import error:
from tensorflow.python.tools import saved_model_util
importError: cannot import name 'saved_model_utils'
saved_model_utils seems to be in the same folder, so not sure what the problem is.
Thank you.