我想知道这里是否有人知道如何将NAO机器人音频流传输到python中的远程模块,以及您是否有示例。我想直接在笔记本电脑上获取NAO音频缓冲区以进行处理,因此无需录制和scp或其他操作。
现在我的问题是这样的:aldebaran网站说,为了远程(在我的笔记本电脑上)接收音频,我必须编写一个继承自ALSoundExtractor的模块。事实是,此类未包含在python
SDK中,因此,如果您要构建一个远程python程序,则不能从Alsoundextractor继承…我已经被这个问题困扰了好几周了,如果有人可以帮助我,那真的很好。
所以这个想法是用
class AudioClassificationModule(ALSoundExtractor):
并具有一个名为process的功能,该功能会自动调用。我收到此错误:
NameError: name 'ALSoundExtractor' is not defined
所以可以归结为:有人可以展示应该怎么做?写一个从ALSoundExtractor继承的python模块,并具有一个对音频有作用的“处理”功能?谢谢!!
文档链接:https : //community.aldebaran-
robotics.com/doc/1-14/naoqi/audio/alaudiodevice-
api.html#ALAudioDeviceProxy
::
subscribe__ssCR
这是一个“小”样本
# -*- coding: utf-8 -*-
###########################################################
# Retrieve robot audio buffer
# Syntaxe:
# python scriptname --pip <ip> --pport <port>
#
# --pip <ip>: specify the ip of your robot (without specification it will use the NAO_IP defined some line below
#
# Author: Alexandre Mazel
###########################################################
NAO_IP = "10.0.252.126" # Romeo on table
#~ NAO_IP = "10.0.253.99" # Nao Alex Blue
from optparse import OptionParser
import naoqi
import numpy as np
import time
import sys
class SoundReceiverModule(naoqi.ALModule):
"""
Use this object to get call back from the ALMemory of the naoqi world.
Your callback needs to be a method with two parameter (variable name, value).
"""
def __init__( self, strModuleName, strNaoIp ):
try:
naoqi.ALModule.__init__(self, strModuleName );
self.BIND_PYTHON( self.getName(),"callback" );
self.strNaoIp = strNaoIp;
self.outfile = None;
self.aOutfile = [None]*(4-1); # ASSUME max nbr channels = 4
except BaseException, err:
print( "ERR: abcdk.naoqitools.SoundReceiverModule: loading error: %s" % str(err) );
# __init__ - end
def __del__( self ):
print( "INF: abcdk.SoundReceiverModule.__del__: cleaning everything" );
self.stop();
def start( self ):
audio = naoqi.ALProxy( "ALAudioDevice", self.strNaoIp, 9559 );
nNbrChannelFlag = 0; # ALL_Channels: 0, AL::LEFTCHANNEL: 1, AL::RIGHTCHANNEL: 2; AL::FRONTCHANNEL: 3 or AL::REARCHANNEL: 4.
nDeinterleave = 0;
nSampleRate = 48000;
audio.setClientPreferences( self.getName(), nSampleRate, nNbrChannelFlag, nDeinterleave ); # setting same as default generate a bug !?!
audio.subscribe( self.getName() );
print( "INF: SoundReceiver: started!" );
# self.processRemote( 4, 128, [18,0], "A"*128*4*2 ); # for local test
# on romeo, here's the current order:
# 0: right; 1: rear; 2: left; 3: front,
def stop( self ):
print( "INF: SoundReceiver: stopping..." );
audio = naoqi.ALProxy( "ALAudioDevice", self.strNaoIp, 9559 );
audio.unsubscribe( self.getName() );
print( "INF: SoundReceiver: stopped!" );
if( self.outfile != None ):
self.outfile.close();
def processRemote( self, nbOfChannels, nbrOfSamplesByChannel, aTimeStamp, buffer ):
"""
This is THE method that receives all the sound buffers from the "ALAudioDevice" module
"""
#~ print( "process!" );
#~ print( "processRemote: %s, %s, %s, lendata: %s, data0: %s (0x%x), data1: %s (0x%x)" % (nbOfChannels, nbrOfSamplesByChannel, aTimeStamp, len(buffer), buffer[0],ord(buffer[0]),buffer[1],ord(buffer[1])) );
#~ print( "raw data: " ),
#~ for i in range( 8 ):
#~ print( "%s (0x%x), " % (buffer[i],ord(buffer[i])) ),
#~ print( "" );
aSoundDataInterlaced = np.fromstring( str(buffer), dtype=np.int16 );
#~ print( "len data: %s " % len( aSoundDataInterlaced ) );
#~ print( "data interlaced: " ),
#~ for i in range( 8 ):
#~ print( "%d, " % (aSoundDataInterlaced[i]) ),
#~ print( "" );
aSoundData = np.reshape( aSoundDataInterlaced, (nbOfChannels, nbrOfSamplesByChannel), 'F' );
#~ print( "len data: %s " % len( aSoundData ) );
#~ print( "len data 0: %s " % len( aSoundData[0] ) );
if( False ):
# compute average
aAvgValue = np.mean( aSoundData, axis = 1 );
print( "avg: %s" % aAvgValue );
if( False ):
# compute fft
nBlockSize = nbrOfSamplesByChannel;
signal = aSoundData[0] * np.hanning( nBlockSize );
aFft = ( np.fft.rfft(signal) / nBlockSize );
print aFft;
if( False ):
# compute peak
aPeakValue = np.max( aSoundData );
if( aPeakValue > 16000 ):
print( "Peak: %s" % aPeakValue );
if( True ):
bSaveAll = True;
# save to file
if( self.outfile == None ):
strFilenameOut = "/out.raw";
print( "INF: Writing sound to '%s'" % strFilenameOut );
self.outfile = open( strFilenameOut, "wb" );
if( bSaveAll ):
for nNumChannel in range( 1, nbOfChannels ):
strFilenameOutChan = strFilenameOut.replace(".raw", "_%d.raw"%nNumChannel);
self.aOutfile[nNumChannel-1] = open( strFilenameOutChan, "wb" );
print( "INF: Writing other channel sound to '%s'" % strFilenameOutChan );
#~ aSoundDataInterlaced.tofile( self.outfile ); # wrote the 4 channels
aSoundData[0].tofile( self.outfile ); # wrote only one channel
#~ print( "aTimeStamp: %s" % aTimeStamp );
#~ print( "data wrotten: " ),
#~ for i in range( 8 ):
#~ print( "%d, " % (aSoundData[0][i]) ),
#~ print( "" );
#~ self.stop(); # make naoqi crashes
if( bSaveAll ):
for nNumChannel in range( 1, nbOfChannels ):
aSoundData[nNumChannel].tofile( self.aOutfile[nNumChannel-1] );
# processRemote - end
def version( self ):
return "0.6";
# SoundReceiver - end
def main():
""" Main entry point
"""
parser = OptionParser()
parser.add_option("--pip",
help="Parent broker port. The IP address or your robot",
dest="pip")
parser.add_option("--pport",
help="Parent broker port. The port NAOqi is listening to",
dest="pport",
type="int")
parser.set_defaults(
pip=NAO_IP,
pport=9559)
(opts, args_) = parser.parse_args()
pip = opts.pip
pport = opts.pport
# We need this broker to be able to construct
# NAOqi modules and subscribe to other modules
# The broker must stay alive until the program exists
myBroker = naoqi.ALBroker("myBroker",
"0.0.0.0", # listen to anyone
0, # find a free port and use it
pip, # parent broker IP
pport) # parent broker port
# Warning: SoundReceiver must be a global variable
# The name given to the constructor must be the name of the
# variable
global SoundReceiver
SoundReceiver = SoundReceiverModule("SoundReceiver", pip)
SoundReceiver.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
print
print "Interrupted by user, shutting down"
myBroker.shutdown()
sys.exit(0)
if __name__ == "__main__":
main()
尝试制作一个简单的音乐机器人,只播放一个链接,但它不连接到语音通道,因此不会出现任何错误,所以我只能放入所有代码。这是我的主要内容。js公司 这是我的音乐机器人命令,我认为它是正确的,因为我已经在这里请求了一些人的帮助。
有没有可能让我的不和谐机器人发送消息,而不必在不和谐中键入命令?相反,我想从我的应用程序内部触发它。 上面的代码给出了一个属性错误:'NoneType'对象没有属性'send'
我希望我的不和谐机器人加入语音频道。但是我遇到了一个问题,每当我想让它加入风投时,什么都不会发生——甚至没有错误。我尝试过SO/Git的其他解决方案,但没有一个适合我(下面有一个)。 编辑:解决了!问题是:没有不和。已安装py[语音]模块。解决方案:
我只是写了一个测试,应该通过webApp下载pdf文件(是的,我知道,我不应该在selenium上做,但是你知道,订单。) 我需要什么? 对于不同的场景,我必须下载不同的pdf,重命名并放置到自定义目录。所以,我必须处理系统模态窗口。一切都很好,所以测试是在远程主机上运行的,当我点击下载文件时,我处理系统模态窗口(我使用机器人包,它是扩展的机器人类,允许我们在远程主机上使用机器人类),所以我使用机
我正在努力让我的机器人进入语音频道,我已经阅读了这里的很多帖子,但没有一篇能够解决我的问题,我正在尝试让我的机器人复制yt视频的声音,但它甚至没有加入,我不知道该怎么办,下面是代码:
我最近制作了我的第一个discord机器人,我终于用下面的代码获得了通过机器人播放的音频。但是,如果与bot处于同一频道的人再次使用同一命令,bot将停止播放其音频并离开该频道。此外,我将如何使它,使机器人无法切换频道之前,它已经完成播放其音频。(注意:bot从包含mp3文件的URL播放音频,而不是使用YouTube插件,因为我只希望它为一些私人服务器播放特定内容)以下是代码: 非常感谢您的帮助。