I'm trying to mix audio files via dummy card by using dmix and dsnoop:
aplay s1.wav &
aplay s2.wav &
arecord -f dat -t wav -d 3 result.wav
But is it possible?
I have only dummy card by:
modprobe snd-dummy
My ~/.asoundrc file is:
defaults.pcm.card 1 #dummy card
pcm.duplex {
type asym
playback.pcm "dmix"
capture.pcm "dsnoop"
}
pcm.!default {
type plug
slave.pcm "duplex"
}
Running on:
CentOS6.5(x86_64)
The snd-dummy driver throws away playback data, and records silence.
For a loopback device, use the snd-aloop driver instead.
Related
It was successful to train from jet son-XAVIER and recognize it as cam. But I don't know how to send the information that jet son-XAVIER recognized in real time to Arduino. The objects we recognize are elk and wild boar. I know that I can only send 1 letter through communication, so elk will send e and wild boar to w. Is there a way to send it as soon as it recognizes it through real-time web cam?
There's not a lot of information here on your setup, but here's a possible solution:
I see the NVIDIA Jetson AGX Xavier module has USB-C ports.
Buy a USB-A to USB-C cable, and plug the Arduino directly in.
I'm not sure what program/language you're using with your trained model, but I'll guess that it's python for now.
You'll want to open a Serial connection to the arduino, and you can do this with pyserial:
https://pypi.org/project/pyserial/
You can send more than just one letter, you can send entire data streams. But, if you want to just send one letter, it will do that as well.
Here's the official documentation for how to communicate with an Arduino using Python:
https://create.arduino.cc/projecthub/ansh2919/serial-communication-between-python-and-arduino-e7cce0
If you're not using python, specify your language of choice, and we can look up and see if it has a serial library.
I have never used darknet but may be this can point you in the right direction.
I have used the library sugested by Bucky and I believe you could add the serial comunication to darknet.py. This is what I would do:
#Add this import at begining of the file darknet.py
import serial
#########################################################
#this is a mocked version of detect in darknet.py, assuming that the labels you used are "elk" and "wildboard". You should not add this lines to the file.
def detect():
res = []
res.append(("elk",0.98,(2,2,50,50)))
res.append(("wildboard",0.98,(2,2,50,50)))
return res
r = detect()
##########################################################
#Add this after the 'print r' at the end of the file darknet.py
ser = serial.Serial('/dev/ttyUSB0') # open serial port. You should check what serial port is assigned to your arduino.
for obj in r:
if obj[0]=="elk" and obj[1]>=0.9: #assuming 0.9 as the minimum confident for a detection
print "found elk"
ser.write('e') # you can send a string with just one letter
elif obj[0]=="wildboard" and obj[1]>=0.9:
print "found wildboard";
ser.write('w') # you can send a string with just one letter
ser.close() # close port
I'm following the wiki https://help.ubuntu.com/community/Xen#Manually_Create_a_PV_Guest_VM
(section "
Set Up Initial Guest Configuration
")
I downloaded the netboot initrd.gz from https://mirror.arizona.edu/ubuntu//ubuntu/dists/bionic/main/installer-amd64/current/images/netboot/xen/
but in the .cfg , what should I specify for the "disk = " line? ---- my host box is not using LVM, so I'll have to use "file-backed storage" for PV disk image. (https://wiki.xenproject.org/wiki/Storage_options , indeed this worked when I gave --dir= instead of --lvm= when running the xml-create command in https://wiki.xenproject.org/wiki/Xen_Project_Beginners_Guide )
here is my current config:
yy#yy-70A4000HUX:~/ub_xen$ cat ub_xen.cfg
name = "ubud1"
kernel = "/home/yy/ub_xen/vmlinuz"
ramdisk = "/home/yy/ub_xen/initrd.gz"
#bootloader = "/usr/lib/xen-4.4/bin/pygrub"
memory = 1024
vcpus = 1
# Custom option for Open vSwitch
vif = [ 'bridge=xenbr0' ]
disk = [ 'vdev=hda,target=/home/yy/ub_xen/images' ]
# You may also consider some other options
# [[http://xenbits.xen.org/docs/4.4-testing/man/xl.cfg.5.html]]
yy#yy-70A4000HUX:~/ub_xen$
I ran the command with sudo xl create -c ub_xen.cfg
this worked fine first, giving me the regular install process on console, pulling install files from remote archive, but when it comes to the step of disk paritioning, it's showing me a "SCSI" partitioning choice, with no volumes / partitions/disks to be chosen.
I guess this is because I'm not setting the right value for "disk = [ ]" option. what should I use here if I use file-backed storage for PV (just like VMware does)?
thanks a lot
Yang
found it, huge thanks to the author here: https://www.systutorials.com/create-and-manage-virtual-machines-on-xen/
My program is supposed to emulate external device that is usually connected via COM port (/dev/ttyUSB0). The program opens a pty and waits for commands. Here is the code:
HostPty::HostPty(const string & HostPty_name)
{
char name[100] = {0};
int res = openpty(&_master, &_slave, name, NULL, NULL);
printf("Name: %s\n", name);
}
string HostPty::nextString()
{
static const int BUF_SIZE = 4096;
char buf[BUF_SIZE];
size_t idx = 0;
while(true)
{
// Read symbols one by one until new line is found
size_t received_size = read(_master, buf + idx, 1);
printf("Received a symbol: %02x\n", buf[idx]);
// Stopping at new line
if(buf[idx] == '\n')
break;
idx++;
}
return string(buf, idx);
}
To test this code I am using miniterm.py terminal emulator connecting to /dev/pty/6 (or whatever is created with openpty) and send text commands over there.
When I type commands manually everything works fine - I receive chars one by one as expected. But when I paste a piece of multiline text this code receives only first byte until I put a new line symbol (even though there are multiple newline symbols in the text I paste).
Any ideas how to fix that?
Any ideas how to fix that?
I don't know which kind of Unix you have. I just tried to reproduce your problem under Linux; but pasting lines work fine on my computer so I cannot reproduce the problem.
If your Unix variant has a system call tracer (Linux: strace, SunOS/Solars: truss, FreeBSD: strace, MacOS: dtruss (?)), I'd trace the system calls:
strace -f -o file_myprog.out ./my_program
miniterm /dev/pty/6
(Note the -f which means that the system calls of sub-processes created by fork() are also debugged. This is necessary because Python will create such sub-processes.)
Now reproduce the situation when the program does not behave correctly and kill my_program using pkill -KILL my_program. (Send the -KILL signal to ensure that my_program is killed immediately.)
Do that again - this time debugging miniterm and killing miniterm in the "wrong situation":
./my_program
strace -f -o file_miniterm.out miniterm /dev/pty/6
At the end of the two output files (file_myprog.out and file_miniterm.out) you can see the last "actions" the two programs were doing before you killed them. There are various scenarios possible:
miniterm was sending the data to /dev/pty/6 but your program did not receive any data. In this case there is a problem with the virtual console itself.
miniterm did not send the data to /dev/pty/6 for some reason. In this case you have a problem with miniterm.
miniterm did not even receive the data pasted using read()...
There are encrypted data bags in json files with some values I need to change. I need to run something like...
$ knife data bag from file show --secret-file path/to/secret DATABAGNAME --config path/to/knife.rb
But this command gives the error: Could not find or open file 'DATABAGNAME' in current directory or in 'data_bags/show/ewe-jenkins'. So obviously the command is not quite right. I need help figuring out the syntax...
I need a command that can be run from the chef-repo, or the data_bags directory, that will allow me to see the unencrypted values of the json file data_bags. Ultimately I want to change some values, but getting the unencrypted values would be a good place to start :) thanks!
Since you're talking about local json files I'll assume you are using chef-zero / local-mode. The json file can indeed be encrypted and the content can be decrypted with knife.
Complete example:
Create key and databag item:
$ openssl rand -base64 512 | tr -d '\r\n' > /tmp/encrypted_data_bag_secret
$ knife data bag create mydatabag secretstuff --secret-file /tmp/encrypted_data_bag_secret -z
Enter this:
{
"id": "secretstuff",
"firstsecret": "must remain secret",
"secondsecret": "also very secret"
}
The json file is indeed encrypted:
# cat data_bags/mydatabag/secretstuff.json
{
"id": "secretstuff",
"firstsecret": {
"encrypted_data": "VafoT8Jc0lp7o4erCxz0WBrJYXjK6j+sJ+WGKJftX4BVF391rA1zWyHpToF0\nqvhn\n",
"iv": "MhG09xFcwFAqX/IA3BusMg==\n",
"version": 1,
"cipher": "aes-256-cbc"
},
"secondsecret": {
"encrypted_data": "Epj+2DuMOsf5MbDCOHEep7S12F6Z0kZ5yMuPv4a3Cr8dcQWCk/pd58OPGQgI\nUJ2J\n",
"iv": "66AcYpoF4xw/rnYfPegPLw==\n",
"version": 1,
"cipher": "aes-256-cbc"
}
}
Show decrypted content with knife:
# knife data bag show mydatabag secretstuff -z --secret-file /tmp/encrypted_data_bag_secret
Encrypted data bag detected, decrypting with provided secret.
firstsecret: must remain secret
id: secretstuff
secondsecret: also very secret
I think you are confusing the knife data bag show and knife data bag from file commands. The former is for displaying data from the server, the latter is for uploading it. You have both on the command line.
I'm recording call via Monitor() Command.
When this command is running i can see two different files (Filename-in.wav and Filename-out.wav) and when Monitor() command is finished it mix those two file and merge them to one (Filename.wav) file.
So the problem is that i want to keep both file after Monitor Cmd Execution but i didn't found a way to do it.
So after the final execution of the Monitor command i will have three file not only one
Ex:
Filename-in.wav
Filename-out.wav
Filename.wav (the mixed one with outbound and inbound voice
So is there any body who can give me an easy solution
You can use custom script for mixmonitor. In that script you can do whatever you want, including files like you described.
http://www.voip-info.org/wiki/view/MixMonitor
Note, that in Filename.wav you have both inbound and outbound in different channels. So you can easy got inbound only by mute left channel and outbound only by mute right channel.
My solution is to change the code of the res_monitore.c and recompile it again.
This is the portion of code that delete the raw file
00295 if (delfiles) {
00296 snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
00297 ast_copy_string(tmp, tmp2, sizeof(tmp));
00298 }
Just we have to add this { delfiles = 0; }in line 00294
00294 delfiles = 0;
00295 if (delfiles) {
00296 snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
00297 ast_copy_string(tmp, tmp2, sizeof(tmp));
00298 }
I changed delfiles = 0 to force the function to not remove the file.
After that this is the command that you have to type :
cd /usr/src/asterisk-1.8.23.0
make
cp ./res/res_monitor.so /res/res_monitor.so.backup
cp ./res/res_monitor.so /usr/lib/asterisk/modules
/etc/ini.d/asterisk restart
and u keep using the Monitor() command as before with the functionality that keep the raw file (Filename-in.wav and Filename-out.wav and of course Filename.wav)
What arheops did not understand in that conversation is that the "command" argument is executed after the "in" and "out" legs have been mixed by (Mix)Monitor.
There is no other way to save the "receive" and "transmit" feeds than to either change the source code as l3on1das suggested (not good practice though), or upgrade to Asterisk 11+, which now (not surprisingly) supports the options -t and -r for MixMonitor() to respectively save the transmitted and received legs in addition to the mixed output.
Good luck to anyone digging in asterisk for speech segmentation.