Re: [bob-devel] What is input data in "preprocess.py "?

25 views
Skip to first unread message

Amir Mohammadi

unread,
Aug 31, 2020, 11:59:06 AM8/31/20
to bob-...@googlegroups.com, bob-devel
Hi,

I think using the Python API is the best approach rather using the preprocessor.py  script.
What you provided as code should work, I think.
I cannot see what went wrong from your report as you replaced the traceback with ... which
is not helpful.

Could you please send a complete code example that I can reproduce your error on my machine?

Thanks,
Amir
On Aug 25 2020, at 5:06 am, 박준우 <jun...@cavuai.com> wrote:
Hi, i 'm currently looking for a way to preprocess a single file ( .wav)
so i found the "preprocess.py", but i don't know what the input file is required here.

first try,
preprocess.py -p energy-2gauss -i /path/wav.wav -o /home/myhome/test.hdf5
RuntimeError: File - constructor: C++ exception caught: 'unregistered extension: .wav'

second try,
preprocess.py -p filename -i /path/wav.wav -o /home/myhome/test.hdf5
nothing.

so i'm written in code.

preprocessor = utils.load_resource("energy-2gauss", "preprocessor")
data = preprocessor.read_original_data(BioFile(1,"wavfile",2), "/home/myhome/", ".wav")
preprocessed = preprocessor(data, None)
....
TypeError: only size-1 arrays can be converted to Python scalars.

I don't know how to use this "preprocess.py".



--
-- You received this message because you are subscribed to the Google Groups bob-devel group. To post to this group, send email to bob-...@googlegroups.com. To unsubscribe from this group, send email to bob-devel+...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/bob-devel or directly the project website at http://idiap.github.com/bob/
---
You received this message because you are subscribed to the Google Groups "bob-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bob-devel+...@googlegroups.com.

JunewooP

unread,
Sep 17, 2020, 4:40:17 AM9/17/20
to bob-devel
hello, sorry for the late reply.

i  solved the above problem. the cause was 'bio_object' parameter. 

i used 'BioFile' object , but it was not an object suitable for 'Spear'
an object suitable for spear is 'AudioBioFile' object.

i attach a part of the code that i solved.

class Bobspear(object):

def __init__(self, audio_name, directory="./"):
self.audio_name = audio_name
self.directory = directory
self.preprocessor, self.extractor, self.algorithm = self._load_resource()
self.init_time = time.time()

def _load_resource(self):

preprocessor = utils.load_resource("energy-2gauss", "preprocessor")
extractor = utils.load_resource("mfcc-60", "extractor")
algorithm = utils.load_resource("gmm-voxforge", "algorithm")
algorithm.load_projector(self.directory + TEMP_PATH +"Projector.hdf5")
return preprocessor, extractor, algorithm

def _get_preprocessed_data(self, bio_object, directory, extension=".wav"):
preprocessed = self.preprocessor.read_original_data(bio_object, directory, extension)
return preprocessed

def _write_feature(self, anotations=None):
preprocessed = self._get_preprocessed_data(AudioBioFile(1, self.audio_name, self.audio_name), self.directory)
extracted = self.extractor(self.preprocessor(preprocessed, anotations))
self.extractor.write_feature(extracted, self.directory+"output.hdf5")

def _compute_score(self):
models, probes = {}, {}
models_list = list()
model_files = [self.directory + MODEL_PATH + dir for dir in os.listdir(self.directory + MODEL_PATH)]
probe_files = [self.directory + "output.hdf5"]

for m in model_files:
models[m] = self.algorithm.read_model(m)
models_list.append(models[m])
for p in probe_files:
probes[p] = self.extractor.read_feature(p)
for p in probe_files:
probes[p] = self.algorithm.project(probes[p])


result = 0.0
for p in probe_files:
for m in model_files:
score = self.algorithm.score(models[m], probes[p])
result = score if score > result else result

return result

the result of this code return scores for one wave file(probe file).

thank you for your reply
2020년 9월 1일 화요일 오전 12시 59분 6초 UTC+9에 amir.mo...@idiap.ch님이 작성:
Reply all
Reply to author
Forward
0 new messages