WebRTC and Google Chrome App - microphone volume adjustment - webrtc

I'm trying to adjust microphone volume in Chrome App. Is is possible to do it? I'm using webrtc.

It's possible
to use WebAudio and a gain filter to adjust the volume
to set the volume of an audio/video tag (on the receiving end)
Here is some sample code for the first option
var audioContext = new AudioContext();
var sourceStream = audioContext.createMediaStreamSource(yourStream);
var gain = audioContext.createGain();
sourceStream.connect(gain);
gain.value = 0.9;
gain.connect(audioContext.destination);
and then use audioContext.createMediaStreamDestination().stream. yourStream is the original stream that you got from getUserMedia().

Related

When requesting azure TTS through the ssml statement, there is a delay of about 2 seconds

As shown in the code below, when azure TTS is requested with the ssml statement, the response is delayed for about 2 seconds.
public static async Task SynthesizeAudioAsync()
{
var config = SpeechConfig.FromSubscription("xxxxxxxxxKey", "xxxxxxxRegion");
using var synthesizer = new SpeechSynthesizer(config, null);
var ssml = File.ReadAllText("C:/ssml.xml");
var result = await synthesizer.SpeakSsmlAsync(ssml); <=== The delay is right here
​ using var stream = AudioDataStream.FromResult(result);
await stream.SaveToWaveFileAsync("C:/file.wav");
}
What is the problem?
Or is it normal for the response speed to be delayed by 2 seconds?
var result = await synthesizer.SpeakSsmlAsync(ssml);
As far as I know, the time taken would be proportional to the data you have in the ssml for it to be converted speech.
What happens in the backend is that : The ssml data is relayed to Azure Speech Services, azure speech service processes the text, builds the required audio bytes using the ML Model returns to the requesting client.
I am assuming the delay you are talking about is the latency for doing the above process. If the data/text to be recognized is large, there will be considerable time in building required audio bytes.
Since you are using await, the code will be waiting until it is completed.

React Native FileSystem file could not be read? What the Blob?

I am trying to send an audio file recorded using expo-av library to my server using web sockets.
Websocket will allow me to only send String, ArrayBuffer or Blob. I spent whole day trying to find out how to convert my .wav recording into a blob but without success. I tried to use expo-file-system method FileSystem.readAsStringAsync to read the filed as a string but I get an error that the file could not be read. How is that possible? I passed it the correct URI (using recording.getURI()).
I tried to re-engineer my approach to use fetch and FormData post request with the same URI and audio gets sent correctly. But I really would like to use WebSockets so that later I could try to make it stream the sound to the server in real time instead of recording it first and then sending it.
You can try ... But I can't find a way to read the blob itself
// this is from my code ...
let recording = Audio.Recording ;
const info = await FileSystem.getInfoAsync(recording.getURI() || "");
console.log(`FILE INFO: ${JSON.stringify(info)}`);
// get the file as a blob
const response = await fetch(info.uri);
const blob = await response.blob(); // slow - Takes a lot of time

How can I restrict data stored on GUN.js browser peers to data they subscribe to ONLY?

I'm new to GUN and it looks very promising for the project I'm working on. One thing I haven't been able to make happen is restricting data on a browser peer to just data that it requests or subscribes to with on(). The following example is my very simple test setup: I have two distinct "conversations", each represented by a distinct data node. One browser gets and puts to a "blue" data node, and the other browser gets and puts to a "red" node. Both browsers sync up to a single server peer. I'd like the server peer to store a copy of all data and each browser to only store the data it subscribes to. Using version 0.9.2.
On Browser1, I run the following:
var peers = ['http://localhost:8080/gun',];
var gun = Gun(peers);
var blue = gun.get('blue');
blue.on(data => console.log('Blue update!', data.message));
On Browser2, I run the following:
var peers = ['http://localhost:8080/gun',];
var gun = Gun(peers);
var red = gun.get('red');
red.on(data => console.log('Red update!', data.message));
The server node runs this:
var http = require('http');
var server = http.createServer();
var Gun = require('gun');
var gun = Gun({web: server});
server.listen(8080, function () {
console.log('Server listening on http://localhost:8080/gun')
})
I then use the console of each browser peer to post some data to the node it is subscribed to. I would expect that each browser's local storage should only contain data for the node it subscribes to, while the server's data.json should contain data for both nodes.
What I see is that the server is storing all data as expected, but in viewing the localstorage I see that the browsers are also storing everything, even the data they've never requested. Is this the intended behavior, or am I missing something? I thought browser peers only store data they subscribed to. While it makes sense for server peers to replicate data to maintain redundancy in the case of failures, I wouldn't want my app clients themselves to be storing countless conversations that they're not a part of.
Thanks for the help!

Using Google Apps Script and Google URL shortener API to get click analytics

in Apps Script, I would like to fetch click statistics for previously generated short URLs via the Google URL shortener API.
I'm afraid I don't really get the API documentation. This is what I tried:
function GetShortUrlClicks() {
var analytics = UrlShortener.Url.get('http://goo.gl/WPN7wo').getAnalytics();
var clicks = analytics.getAllTime();
Logger.log(clicks)
}
It seems that the variable analytics is undefined and thus the next line throws an error.
Any help is much appreciated.
You are missing the optional args required to get the Analytics data back.
This function ought to work -
function GetShortUrlClicks() {
var analytics = UrlShortener.Url.get('http://goo.gl/WPN7wo',{projection:'FULL'}).getAnalytics();
var clicks = analytics.getAllTime();
Logger.log(clicks)
}
You can use more see more reference here - https://developers.google.com/url-shortener/v1/url/get

Can I uniquely identify a device in Windows 10/Windows 8/WinRT

Is there any mechanism to identify a device uniquely (even if it is anonymous)?
To be clear, by "device" I mean the computer/slate/pc.
Windows 8.x
http://codepaste.net/ybt893
string HardwareId()
{
var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
var bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
Windows 10
You must add the Mobile and/or Desktop extension SDK.
string HardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
var bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
Such an ability has just been added in Windows 8 RTM:
Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null)
There doesn't seem to be a convenient way for Metro Style apps in Windows 8 to obtain a system-maintained unique identifier, like Windows Phone 7 provided with its Microsoft.Phone.Info.DeviceExtendedProperties.GetValue( "DeviceUniqueId" )
http://social.msdn.microsoft.com/Forums/en-HK/winappswithcsharp/thread/62ac2a48-be60-465c-b3b7-bbb736a67a60
http://social.msdn.microsoft.com/Forums/en-NZ/winappswithcsharp/thread/2ca0d5de-9db5-4349-839c-e01ff614ec6e
The best solution I've found so far is to simply generate a new guid in application local storage and use that identifier to identify the computer for the current and future launches of your app.
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
Object value = localSettings.Values["uniqueDeviceId"];
if (!value)
{
value = Guid.NewGuid();
localSettings.Values["uniqueDeviceId"] = value;
}
Keep in mind that the user could delete the local storage and cause your app to forget and regenerate that value (or potentially even modify/spoof the value), so don't depend on it for any critical security purposes. Since I'm only using this technique for rough statistics and usage reporting, this is fine for my needs.
Could this be used as a consistent ID for the logged in user?
http://msdn.microsoft.com/en-us/library/windows/apps/windows.security.exchangeactivesyncprovisioning.easclientdeviceinformation.id.aspx
EasClientDeviceInformation.Id | id property
Returns the identifier of the local computer. The Id property represents the DeviceId using the GUID truncated from the first 16 bytes of the SHA256 hash of MachineID, User SID, and App ID where the MachineID uses the SID of the local users group. Each component of the GUID is returned in network byte order.