Tested in OSX 10.11.5. When I run the exp, it freezes.
Console msg:
Portmidi warning: no midi device found!
Portmidi closed.
Which version of PsychoPy are you using? Is this the latest standalone?
I'm using the latest standalone version 1.84.2.
I think @jeremygray is an expert for Pyo on Mac? :)
not an expert by any stretch of the imagination, but I have some experience, yes. :-)
@lucaf -- please elaborate how you are using voicekey, and why you think the problem is voicekey.pyo_init(). Does the microphone and sound work for you using pyo? If not, does regular sound work at all using something other than pyo?
The messages about Portmidi are harmless (just annoying).
I'm on OSX 10.11.6, and this minimal test works for me:
>>> from psychopy import voicekey
>>> voicekey.pyo_init()
Hi Jeremy,
your minimal test works, but if you just add a sound component (see attachment), it hangs...
I think there must be a sort of conflict with the sound module.
Thx,
L.
Oh! I forgot to tell that yes, microphone and sound work for me using pyo.
L.
An update: I manage to get it working using only a single instance of the pyo server (I share the one instantiated in the sound module with the voicekey module).
However, I have another issue now: I get a trigger on no speech. I might be wrong, but from the code looks like the data chunks which provide the baseline value are processed differently from the one compared against it. The latter are modified by the following instruction:
chunk = np.int16(chunk * 2 ** 15)
I'm using an OnsetVoiceKey object for the detection.
Yes, there should only ever be a single pyo server.
I'll look into the baseline code.
Thanks for this thread! I am running into the same issues as @lucaf
How can I share one instance of a pyo server created by sound module with the voicekey module?
I have already read through the source codes, but can't figure it out myself.
Help would be very appreciated.
Thanks :)
Hi Hans,
in generally, when I found some issue in PsychoPy, I do not like to
modify the source code.
So, if I can, I do monkey patch. For the voicekey problem I wrote about, I
created a new python module (see attachment).
You just need to import that module in your experiment at the very
beginning and that's it. It should work.
Cheers,
L.
On Mon, Jan 30, 2017 at 12:36 AM, hansluft notifications@github.com wrote:
Thanks for this thread! I am running into the same issues as @lucaf
https://github.com/lucaf
How can I share one instance of a pyo server created by sound module with
the voicekey module?
I have already read through the source codes, but can't figure it out
myself.
Help would be very appreciated.
Thanks :)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/psychopy/psychopy/issues/1282#issuecomment-275955728,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAOYTODgdHX9pfIk38HGSmyzJBVQ8BByks5rXSJ_gaJpZM4KaVLu
.
Hej lucaf,
Thank you so much for your help.
I am new to github, so maybe I am missing something, but it seems like there is no attachment, neither in the email nor in the thread.
How/where can I find your patch?
Thanks,
hans
On 1 Feb 2017, at 14:49, lucaf notifications@github.com wrote:
Hi Hans,
in generally, when I found some issue in PsychoPy, I do not like to
modify the source code.
So, if I can, I do monkey patch. For the voicekey problem I wrote about, I
created a new python module (see attachment).
You just need to import that module in your experiment at the very
beginning and that's it. It should work.Cheers,
L.On Mon, Jan 30, 2017 at 12:36 AM, hansluft notifications@github.com wrote:
Thanks for this thread! I am running into the same issues as @lucaf
https://github.com/lucaf
How can I share one instance of a pyo server created by sound module with
the voicekey module?
I have already read through the source codes, but can't figure it out
myself.
Help would be very appreciated.
Thanks :)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/psychopy/psychopy/issues/1282#issuecomment-275955728,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAOYTODgdHX9pfIk38HGSmyzJBVQ8BByks5rXSJ_gaJpZM4KaVLu
.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
Yep, sorry. Here's the code
from psychopy import voicekey, sound
import numpy as np
import sys
import time
import pyo64 as pyo
# --- VOICE KEY PATCH - ON ---
def _pyo_init_patched(rate = 44100, nchnls = 1, buffersize = 32, duplex = 1):
sound.initPyo(rate = rate, stereo = True, buffer = buffersize)
voicekey.pyo_server = vks = sound.pyoSndServer
vks.setDuplex(duplex)
# avoid mac issue of losing first 0.5s if no sound played for ~1 minute:
if sys.platform == 'darwin':
z2 = np.zeros(2)
_sndTable = pyo.DataTable(size = 2, init = z2.T.tolist(), chnls = vks.getNchnls())
_snd = pyo.TableRead(_sndTable, freq = rate, mul=0)
_snd.play()
time.sleep(0.510)
__voicekey_pyo_init = voicekey.pyo_init
voicekey.pyo_init = _pyo_init_patched
def _BaseVoiceKey_set_baseline_patched(self):
data = np.int16(np.array(self._baselinetable.getTable()) * 2 ** 15) # *2 ** 15 (patch 1)
if self.config['more_processing']: # calculate noise on the seleted band only, if more_processing... (patch 2)
data = voicekey.vk_tools.bandpass(data, self.config['low'], self.config['high'], self.rate)
tstart = int(voicekey.T_BASELINE_ON * self.rate)
segment_power = voicekey.vk_tools.rms(data[tstart:])
# Look for bad baseline period:
if self.baseline > voicekey.TOO_LOUD:
self.bad_baseline = True
# Dubiously quiet is bad too:
if segment_power < voicekey.TOO_QUIET:
self.stop()
msg = ('Baseline period is TOO quiet\nwrong input '
'channel selected? device-related initial delay?')
raise ValueError(msg)
self.baseline = max(segment_power, 1)
__voicekey_TOO_LOUD = voicekey.TOO_LOUD
__voicekey_TOO_QUIET = voicekey.TOO_QUIET
__voicekey__BaseVoiceKey_set_baseline = voicekey._BaseVoiceKey._set_baseline
voicekey.TOO_LOUD = voicekey.TOO_LOUD * 2 ** 15
voicekey.TOO_QUIET = voicekey.TOO_QUIET * 2 ** 15
voicekey._BaseVoiceKey._set_baseline = _BaseVoiceKey_set_baseline_patched
Cheers,
L.
Thanks!! That's great!
On 3 Feb 2017, at 12:32, lucaf notifications@github.com wrote:
Yep, sorry. Here's the code
from psychopy import voicekey, sound
import numpy as np
import sys
import time
import pyo64 as pyo--- VOICE KEY PATCH - ON ---
def _pyo_init_patched(rate = 44100, nchnls = 1, buffersize = 32, duplex = 1):
sound.initPyo(rate = rate, stereo = True, buffer = buffersize)
voicekey.pyo_server = vks = sound.pyoSndServer
vks.setDuplex(duplex)# avoid mac issue of losing first 0.5s if no sound played for ~1 minute: if sys.platform == 'darwin': z2 = np.zeros(2) _sndTable = pyo.DataTable(size = 2, init = z2.T.tolist(), chnls = vks.getNchnls()) _snd = pyo.TableRead(_sndTable, freq = rate, mul=0) _snd.play() time.sleep(0.510)__voicekey_pyo_init = voicekey.pyo_init
voicekey.pyo_init = _pyo_init_patcheddef _BaseVoiceKey_set_baseline_patched(self):
data = np.int16(np.array(self._baselinetable.getTable()) * 2 * 15) # *2 * 15 (patch 1)if self.config['more_processing']: # calculate noise on the seleted band only, if more_processing... (patch 2) data = voicekey.vk_tools.bandpass(data, self.config['low'], self.config['high'], self.rate) tstart = int(voicekey.T_BASELINE_ON * self.rate) segment_power = voicekey.vk_tools.rms(data[tstart:]) # Look for bad baseline period: if self.baseline > voicekey.TOO_LOUD: self.bad_baseline = True # Dubiously quiet is bad too: if segment_power < voicekey.TOO_QUIET: self.stop() msg = ('Baseline period is TOO quiet\nwrong input ' 'channel selected? device-related initial delay?') raise ValueError(msg) self.baseline = max(segment_power, 1)__voicekey_TOO_LOUD = voicekey.TOO_LOUD
__voicekey_TOO_QUIET = voicekey.TOO_QUIET
__voicekey__BaseVoiceKey_set_baseline = voicekey._BaseVoiceKey._set_baselinevoicekey.TOO_LOUD = voicekey.TOO_LOUD * 2 * 15
voicekey.TOO_QUIET = voicekey.TOO_QUIET * 2 * 15
voicekey._BaseVoiceKey._set_baseline = _BaseVoiceKey_set_baseline_patched
Cheers,
L.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.