Discussion:
[asterisk-dev] Regarding realtime audio streaming from mixmonitor
Mani Kanta Gadde
2018-07-06 07:58:29 UTC
Permalink
Hi,
We are trying to stream audio coming from calls to an NLP engine to get the
text transcription, for this we created a socket in *app_mixmonitor.c* and
we are writing audio frames to socket descriptor. We have tried with
TCP(SOCK_STREAM) and UDP(SOCK_DGRAM) protocols to send the audio frames to
the socket server.

We are using latest asterisk complied from GitHub source code (asterisk
repo).

Here are some of the suggestions I found on asterisk forums
http://forums.asterisk.org/viewtopic.php?f=13&t=89365#p196720
on this thread, it was suggested to use CHANSPY, but we have edited
mixmonitor code to both record and stream in realtime, which has sufficed
our needs.

Here is the socket code we used inside the *mixmonitor_thread* function in
app_mixmonitor.c file.

+
+ int sockfd;
+ char buffer[1024];
+ char *hello = "Hello from client";
+ struct sockaddr_in servaddr;
+
+ // Creating socket file descriptor
+ if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) {
+ ast_log(LOG_NOTICE, "socket creation failed");
+// exit(EXIT_FAILURE);
+ }
+
+ memset(&servaddr, 0, sizeof(servaddr));
+
+ // Filling server information
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons(8080);
+ servaddr.sin_addr.s_addr = INADDR_ANY;
+
+ if (connect(sockfd,(struct sockaddr *) &servaddr,sizeof(servaddr)) < 0)
+ ast_log(LOG_ERROR, "ERROR connecting\n");
+ ast_log(LOG_NOTICE, "socket connected with server \n");
+
+ //socket code ends here

and here is the code of writing audio frames to the socket.

for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
ast_writestream(*fs, cur);
+ // writing to socket
+ write(sockfd, cur->data.ptr, cur->datalen);
}


And we were able to see the frames on the other side of the socket.

We want to ask you if there is any other better approach to stream audio in
real time.

Thanks & Regards
Manikanta
Zemoso Technologies
Jean Aunis
2018-07-06 09:00:50 UTC
Permalink
Hi,
We are trying to stream audio coming from calls to an NLP engine to
get the text transcription, for this we created a socket
in_app_mixmonitor.c_ and we are writing audio frames to socket
descriptor. We have tried with TCP(SOCK_STREAM) and UDP(SOCK_DGRAM)
protocols to send the audio frames to the socket server.
We are using latest asterisk complied from GitHub source code
(asterisk repo).
Here are some of the suggestions I found on asterisk forums
http://forums.asterisk.org/viewtopic.php?f=13&t=89365#p196720
on this thread, it was suggested to use CHANSPY, but we have edited
mixmonitor code to both record and stream in realtime, which has
sufficed our needs.
Here is the socket code we used inside the_mixmonitor_thread_function
in app_mixmonitor.c file.
<snip>
As suggested in the forum, it is probably easier to do this with the
ChanSpy application, combined with a UnicastRTP channel.

Regards

Jean Aunis
Dennis Guse
2018-07-09 20:56:18 UTC
Permalink
Hi Mani,

just out of curiosity: what is your actual goal?
Do you need to create the transcriptions live or afterwards?

Best,
Dennis
Hi, 
We are trying to stream audio coming from calls to an NLP engine to get the text transcription, for this we created a socket in app_mixmonitor.c and we are writing audio frames to socket descriptor.
We have tried with TCP(SOCK_STREAM) and UDP(SOCK_DGRAM) protocols to send the audio frames to the socket server. 
We are using latest asterisk complied from GitHub source code (asterisk repo).
Here are some of the suggestions I found on asterisk forums 
http://forums.asterisk.org/viewtopic.php?f=13&t=89365#p196720
on this thread, it was suggested to use CHANSPY, but we have edited mixmonitor code to both record and stream in realtime, which has sufficed our needs.
Here is the socket code we used inside the mixmonitor_thread function in app_mixmonitor.c file.
+
+ int sockfd;
+ char buffer[1024];
+ char *hello = "Hello from client";
+ struct sockaddr_in servaddr;
+
+ // Creating socket file descriptor
+ if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) {
+ ast_log(LOG_NOTICE, "socket creation failed");
+// exit(EXIT_FAILURE);
+ }
+
+ memset(&servaddr, 0, sizeof(servaddr));
+
+ // Filling server information
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons(8080);
+ servaddr.sin_addr.s_addr = INADDR_ANY;
+
+ if (connect(sockfd,(struct sockaddr *) &servaddr,sizeof(servaddr)) < 0)
+ ast_log(LOG_ERROR, "ERROR connecting\n");
+ ast_log(LOG_NOTICE, "socket connected with server \n");
+
+ //socket code ends here
and here is the code of writing audio frames to the socket.
for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
  ast_writestream(*fs, cur);
+ // writing to socket
+ write(sockfd, cur->data.ptr, cur->datalen);
}
And we were able to see the frames on the other side of the socket. 
We want to ask you if there is any other better approach to stream audio in real time.
Thanks & Regards 
Manikanta
Zemoso Technologies
--
Dennis Guse
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.dig
Mani Kanta Gadde
2018-07-10 05:48:06 UTC
Permalink
Hi Dennis,
I want to see the transcription while I am on a call, so I looking for
real-time transcriptions.

Thanks & Regards
Manikanta
Post by Dennis Guse
Hi Mani,
just out of curiosity: what is your actual goal?
Do you need to create the transcriptions live or afterwards?
Best,
Dennis
Post by Mani Kanta Gadde
Hi,
We are trying to stream audio coming from calls to an NLP engine to get
the text transcription, for this we created a socket
in app_mixmonitor.c and we are writing audio frames to socket descriptor.
Post by Mani Kanta Gadde
We have tried with TCP(SOCK_STREAM) and UDP(SOCK_DGRAM) protocols to
send the audio frames to the socket server.
Post by Mani Kanta Gadde
We are using latest asterisk complied from GitHub source code (asterisk
repo).
Post by Mani Kanta Gadde
Here are some of the suggestions I found on asterisk forums
http://forums.asterisk.org/viewtopic.php?f=13&t=89365#p196720
on this thread, it was suggested to use CHANSPY, but we have edited
mixmonitor code to both record and stream in realtime, which has sufficed
our needs.
Post by Mani Kanta Gadde
Here is the socket code we used inside the mixmonitor_thread function in
app_mixmonitor.c file.
Post by Mani Kanta Gadde
+
+ int sockfd;
+ char buffer[1024];
+ char *hello = "Hello from client";
+ struct sockaddr_in servaddr;
+
+ // Creating socket file descriptor
+ if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) {
+ ast_log(LOG_NOTICE, "socket creation failed");
+// exit(EXIT_FAILURE);
+ }
+
+ memset(&servaddr, 0, sizeof(servaddr));
+
+ // Filling server information
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons(8080);
+ servaddr.sin_addr.s_addr = INADDR_ANY;
+
+ if (connect(sockfd,(struct sockaddr *) &servaddr,sizeof(servaddr)) < 0)
+ ast_log(LOG_ERROR, "ERROR connecting\n");
+ ast_log(LOG_NOTICE, "socket connected with server \n");
+
+ //socket code ends here
and here is the code of writing audio frames to the socket.
for (cur = fr; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
ast_writestream(*fs, cur);
+ // writing to socket
+ write(sockfd, cur->data.ptr,
cur->datalen);
Post by Mani Kanta Gadde
}
And we were able to see the frames on the other side of the socket.
We want to ask you if there is any other better approach to stream audio
in real time.
Post by Mani Kanta Gadde
Thanks & Regards
Manikanta
Zemoso Technologies
--
Dennis Guse
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-dev mailing list
http://lists.digium.com/mailman/listinfo/asterisk-dev
Loading...