Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
1559
gaia/distros/spark/apps/mozspeechcollect/js/binary.js
Executable file
1559
gaia/distros/spark/apps/mozspeechcollect/js/binary.js
Executable file
File diff suppressed because it is too large
Load diff
92
gaia/distros/spark/apps/mozspeechcollect/js/recorder.js
Executable file
92
gaia/distros/spark/apps/mozspeechcollect/js/recorder.js
Executable file
|
|
@ -0,0 +1,92 @@
|
|||
(function(window){
|
||||
|
||||
var WORKER_PATH = 'js/recorderWorker.js';
|
||||
|
||||
var Recorder = function(source, cfg){
|
||||
var config = cfg || {};
|
||||
var bufferLen = config.bufferLen || 4096;
|
||||
var numChannels = config.numChannels || 2;
|
||||
this.context = source.context;
|
||||
this.node = (this.context.createScriptProcessor ||
|
||||
this.context.createJavaScriptNode).call(this.context,
|
||||
bufferLen, numChannels, numChannels);
|
||||
var worker = new Worker(config.workerPath || WORKER_PATH);
|
||||
worker.postMessage({
|
||||
command: 'init',
|
||||
config: {
|
||||
sampleRate: this.context.sampleRate,
|
||||
numChannels: numChannels
|
||||
}
|
||||
});
|
||||
var recording = false,
|
||||
currCallback;
|
||||
|
||||
this.node.onaudioprocess = function(e){
|
||||
if (!recording) return;
|
||||
var buffer = [];
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
buffer.push(e.inputBuffer.getChannelData(channel));
|
||||
}
|
||||
worker.postMessage({
|
||||
command: 'record',
|
||||
buffer: buffer
|
||||
});
|
||||
}
|
||||
|
||||
this.configure = function(cfg){
|
||||
for (var prop in cfg){
|
||||
if (cfg.hasOwnProperty(prop)){
|
||||
config[prop] = cfg[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.record = function(){
|
||||
recording = true;
|
||||
}
|
||||
|
||||
this.stop = function(){
|
||||
recording = false;
|
||||
}
|
||||
|
||||
this.clear = function(){
|
||||
worker.postMessage({ command: 'clear' });
|
||||
}
|
||||
|
||||
this.getBuffer = function(cb) {
|
||||
currCallback = cb || config.callback;
|
||||
worker.postMessage({ command: 'getBuffer' })
|
||||
}
|
||||
|
||||
this.exportWAV = function(cb, type){
|
||||
currCallback = cb || config.callback;
|
||||
type = type || config.type || 'audio/wav';
|
||||
if (!currCallback) throw new Error('Callback not set');
|
||||
worker.postMessage({
|
||||
command: 'exportWAV',
|
||||
type: type
|
||||
});
|
||||
}
|
||||
|
||||
worker.onmessage = function(e){
|
||||
var blob = e.data;
|
||||
currCallback(blob);
|
||||
}
|
||||
|
||||
source.connect(this.node);
|
||||
this.node.connect(this.context.destination); //this should not be necessary
|
||||
};
|
||||
|
||||
Recorder.forceDownload = function(blob, filename){
|
||||
var url = (window.URL || window.webkitURL).createObjectURL(blob);
|
||||
var link = window.document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename || 'output.wav';
|
||||
var click = document.createEvent("Event");
|
||||
click.initEvent("click", true, true);
|
||||
link.dispatchEvent(click);
|
||||
}
|
||||
|
||||
window.Recorder = Recorder;
|
||||
|
||||
})(window);
|
||||
147
gaia/distros/spark/apps/mozspeechcollect/js/recorderWorker.js
Executable file
147
gaia/distros/spark/apps/mozspeechcollect/js/recorderWorker.js
Executable file
|
|
@ -0,0 +1,147 @@
|
|||
var recLength = 0,
|
||||
recBuffers = [],
|
||||
sampleRate,
|
||||
numChannels;
|
||||
|
||||
this.onmessage = function(e){
|
||||
switch(e.data.command){
|
||||
case 'init':
|
||||
init(e.data.config);
|
||||
break;
|
||||
case 'record':
|
||||
record(e.data.buffer);
|
||||
break;
|
||||
case 'exportWAV':
|
||||
exportWAV(e.data.type);
|
||||
break;
|
||||
case 'getBuffer':
|
||||
getBuffer();
|
||||
break;
|
||||
case 'clear':
|
||||
clear();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
function init(config){
|
||||
sampleRate = config.sampleRate;
|
||||
numChannels = config.numChannels;
|
||||
initBuffers();
|
||||
}
|
||||
|
||||
function record(inputBuffer){
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
recBuffers[channel].push(inputBuffer[channel]);
|
||||
}
|
||||
recLength += inputBuffer[0].length;
|
||||
}
|
||||
|
||||
function exportWAV(type){
|
||||
var buffers = [];
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
buffers.push(mergeBuffers(recBuffers[channel], recLength));
|
||||
}
|
||||
if (numChannels === 2){
|
||||
var interleaved = interleave(buffers[0], buffers[1]);
|
||||
} else {
|
||||
var interleaved = buffers[0];
|
||||
}
|
||||
var dataview = encodeWAV(interleaved);
|
||||
var audioBlob = new Blob([dataview], { type: type });
|
||||
|
||||
this.postMessage(audioBlob);
|
||||
}
|
||||
|
||||
function getBuffer(){
|
||||
var buffers = [];
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
buffers.push(mergeBuffers(recBuffers[channel], recLength));
|
||||
}
|
||||
this.postMessage(buffers);
|
||||
}
|
||||
|
||||
function clear(){
|
||||
recLength = 0;
|
||||
recBuffers = [];
|
||||
initBuffers();
|
||||
}
|
||||
|
||||
function initBuffers(){
|
||||
for (var channel = 0; channel < numChannels; channel++){
|
||||
recBuffers[channel] = [];
|
||||
}
|
||||
}
|
||||
|
||||
function mergeBuffers(recBuffers, recLength){
|
||||
var result = new Float32Array(recLength);
|
||||
var offset = 0;
|
||||
for (var i = 0; i < recBuffers.length; i++){
|
||||
result.set(recBuffers[i], offset);
|
||||
offset += recBuffers[i].length;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function interleave(inputL, inputR){
|
||||
var length = inputL.length + inputR.length;
|
||||
var result = new Float32Array(length);
|
||||
|
||||
var index = 0,
|
||||
inputIndex = 0;
|
||||
|
||||
while (index < length){
|
||||
result[index++] = inputL[inputIndex];
|
||||
result[index++] = inputR[inputIndex];
|
||||
inputIndex++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function floatTo16BitPCM(output, offset, input){
|
||||
for (var i = 0; i < input.length; i++, offset+=2){
|
||||
var s = Math.max(-1, Math.min(1, input[i]));
|
||||
output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true);
|
||||
}
|
||||
}
|
||||
|
||||
function writeString(view, offset, string){
|
||||
for (var i = 0; i < string.length; i++){
|
||||
view.setUint8(offset + i, string.charCodeAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
function encodeWAV(samples){
|
||||
var buffer = new ArrayBuffer(44 + samples.length * 2);
|
||||
var view = new DataView(buffer);
|
||||
|
||||
/* RIFF identifier */
|
||||
writeString(view, 0, 'RIFF');
|
||||
/* RIFF chunk length */
|
||||
view.setUint32(4, 36 + samples.length * 2, true);
|
||||
/* RIFF type */
|
||||
writeString(view, 8, 'WAVE');
|
||||
/* format chunk identifier */
|
||||
writeString(view, 12, 'fmt ');
|
||||
/* format chunk length */
|
||||
view.setUint32(16, 16, true);
|
||||
/* sample format (raw) */
|
||||
view.setUint16(20, 1, true);
|
||||
/* channel count */
|
||||
view.setUint16(22, numChannels, true);
|
||||
/* sample rate */
|
||||
view.setUint32(24, sampleRate, true);
|
||||
/* byte rate (sample rate * block align) */
|
||||
view.setUint32(28, sampleRate * 4, true);
|
||||
/* block align (channel count * bytes per sample) */
|
||||
view.setUint16(32, numChannels * 2, true);
|
||||
/* bits per sample */
|
||||
view.setUint16(34, 16, true);
|
||||
/* data chunk identifier */
|
||||
writeString(view, 36, 'data');
|
||||
/* data chunk length */
|
||||
view.setUint32(40, samples.length * 2, true);
|
||||
|
||||
floatTo16BitPCM(view, 44, samples);
|
||||
|
||||
return view;
|
||||
}
|
||||
43
gaia/distros/spark/apps/mozspeechcollect/js/user.js
Executable file
43
gaia/distros/spark/apps/mozspeechcollect/js/user.js
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
pref('browser.manifestURL', "app://system.gaiamobile.org/manifest.webapp");
|
||||
pref('b2g.system_manifest_url', "app://system.gaiamobile.org/manifest.webapp");
|
||||
pref('b2g.neterror.url', "app://system.gaiamobile.org/net_error.html");
|
||||
pref('browser.homescreenURL', "app://system.gaiamobile.org/index.html");
|
||||
pref('b2g.system_startup_url', "app://system.gaiamobile.org/index.html");
|
||||
pref('network.http.max-connections-per-server', 15);
|
||||
pref('dom.mozInputMethod.enabled', true);
|
||||
pref('layout.css.sticky.enabled', true);
|
||||
pref('intl.uidirection.ar-x-psbidi', "rtl");
|
||||
pref('dom.webcomponents.enabled', true);
|
||||
pref('ril.debugging.enabled', false);
|
||||
pref('dom.mms.version', 17);
|
||||
pref('b2g.wifi.allow_unsafe_wpa_eap', true);
|
||||
pref('network.dns.localDomains', "gaiamobile.org,email.gaiamobile.org,gallery.gaiamobile.org,search.gaiamobile.org,video.gaiamobile.org,music.gaiamobile.org,fl.gaiamobile.org,collection.gaiamobile.org,ftu.gaiamobile.org,wappush.gaiamobile.org,communications.gaiamobile.org,camera.gaiamobile.org,fm.gaiamobile.org,bluetooth.gaiamobile.org,marketplace.firefox.com.gaiamobile.org,sms.gaiamobile.org,findmydevice.gaiamobile.org,verticalhome.gaiamobile.org,sharedtest.gaiamobile.org,keyboard.gaiamobile.org,browser.gaiamobile.org,wallpaper.gaiamobile.org,emergency-call.gaiamobile.org,costcontrol.gaiamobile.org,bookmark.gaiamobile.org,settings.gaiamobile.org,operatorvariant.gaiamobile.org,clock.gaiamobile.org,system.gaiamobile.org,callscreen.gaiamobile.org,homescreen.gaiamobile.org,pdfjs.gaiamobile.org,calendar.gaiamobile.org,ringtones.gaiamobile.org,feedback.gaiamobile.org,sheet-app-1.gaiamobile.org,uitest.gaiamobile.org,test-container.gaiamobile.org,contacts-manager.gaiamobile.org,test-sensors.gaiamobile.org,test-receiver-2.gaiamobile.org,test-otasp.gaiamobile.org,contacts-ds-provider2.gaiamobile.org,marketplace-dev.allizom.org.gaiamobile.org,template.gaiamobile.org,test-ime.gaiamobile.org,demo-keyboard.gaiamobile.org,test-fxa-client.gaiamobile.org,test-receiver-1.gaiamobile.org,music2.gaiamobile.org,marketplace.allizom.org.gaiamobile.org,test-findmydevice.gaiamobile.org,ds-test.gaiamobile.org,sheet-app-3.gaiamobile.org,test-iac-subscriber.gaiamobile.org,image-uploader.gaiamobile.org,test-iac-publisher.gaiamobile.org,homescreen-stingray.gaiamobile.org,uitest-privileged.gaiamobile.org,test-agent.gaiamobile.org,test-keyboard-app.gaiamobile.org,test-receiver-inline.gaiamobile.org,bookmarks-reader.gaiamobile.org,sheet-app-2.gaiamobile.org,in_app_pay_test.gaiamobile.org,share-receiver.gaiamobile.org,contacts-ds-provider1.gaiamobile.org,mochitest.gaiamobile.org,testpermission.gaiamobile.org,crystalskull.gaiamobile.org,test-wappush.gaiamobile.org,membuster.gaiamobile.org,cubevid.gaiamobile.org,geoloc.gaiamobile.org");
|
||||
|
||||
pref("geo.gps.supl_server", "supl.izatcloud.net");
|
||||
pref("geo.gps.supl_port", 22024);
|
||||
pref("dom.payment.provider.0.name", "firefoxmarket");
|
||||
pref("dom.payment.provider.0.description", "marketplace.firefox.com");
|
||||
pref("dom.payment.provider.0.uri", "https://marketplace.firefox.com/mozpay/?req=");
|
||||
pref("dom.payment.provider.0.type", "mozilla/payments/pay/v1");
|
||||
pref("dom.payment.provider.0.requestMethod", "GET");
|
||||
pref("dom.payment.skipHTTPSCheck", true);
|
||||
pref("dom.payment.debug", true);
|
||||
|
||||
pref("dom.payment.provider.1.name", "firefoxmarketdev");
|
||||
pref("dom.payment.provider.1.description", "marketplace-dev.allizom.org");
|
||||
pref("dom.payment.provider.1.uri", "https://marketplace-dev.allizom.org/mozpay/?req=");
|
||||
pref("dom.payment.provider.1.type", "mozilla-dev/payments/pay/v1");
|
||||
pref("dom.payment.provider.1.requestMethod", "GET");
|
||||
|
||||
pref("dom.payment.provider.2.name", "firefoxmarketstage");
|
||||
pref("dom.payment.provider.2.description", "marketplace.allizom.org");
|
||||
pref("dom.payment.provider.2.uri", "https://marketplace.allizom.org/mozpay/?req=");
|
||||
pref("dom.payment.provider.2.type", "mozilla-stage/payments/pay/v1");
|
||||
pref("dom.payment.provider.2.requestMethod", "GET");
|
||||
|
||||
pref("dom.payment.provider.3.name", "mockpayprovider");
|
||||
pref("dom.payment.provider.3.description", "Mock Payment Provider");
|
||||
pref("dom.payment.provider.3.uri", "http://ferjm.github.io/gaia-mock-payment-provider/index.html?req=");
|
||||
pref("dom.payment.provider.3.type", "tests/payments/pay/v1");
|
||||
pref("dom.payment.provider.3.requestMethod", "GET");
|
||||
|
||||
220
gaia/distros/spark/apps/mozspeechcollect/js/vdialer.js
Executable file
220
gaia/distros/spark/apps/mozspeechcollect/js/vdialer.js
Executable file
|
|
@ -0,0 +1,220 @@
|
|||
var client = new BinaryClient('ws://speechan.cloudapp.net:9000');
|
||||
var speakbtn = document.querySelector("#speak");
|
||||
var sayaudio = document.querySelector("#say");
|
||||
var recognizing = false;
|
||||
var final_transcript = "";
|
||||
var _stream;
|
||||
var sr;
|
||||
var offline = true;
|
||||
var global_phrase;
|
||||
var audio_context = new AudioContext;
|
||||
var recorder;
|
||||
var str_grm = "#JSGF V1.0; grammar test; <numeros> = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ; public <numbers> = <numeros>+;"
|
||||
var blob = null;
|
||||
localStorage.setItem("totalsamples", 0 );
|
||||
|
||||
// Wait for connection to BinaryJS server
|
||||
client.on('open', function(){
|
||||
offline = false;
|
||||
changelabel("You are connected. Please, push the microphone to start testing.");
|
||||
});
|
||||
|
||||
// Wait for connection to BinaryJS server
|
||||
client.on('error', function(){
|
||||
offline = true;
|
||||
changelabel("Sorry, you are offline. Please, restart the application.");
|
||||
alert("You have disconnected. Please, restart the appplication.");
|
||||
});
|
||||
|
||||
navigator.mozGetUserMedia({audio: true},
|
||||
function(stream){
|
||||
// if everything ok
|
||||
var options = {};
|
||||
_stream = stream;
|
||||
success_gum(_stream) ;
|
||||
nomike = false;
|
||||
} ,
|
||||
function(_error){
|
||||
if (error) error(_error)
|
||||
nomike = true;
|
||||
}
|
||||
);
|
||||
|
||||
function success_gum(stream){
|
||||
var input = audio_context.createMediaStreamSource(stream);
|
||||
console.log('Media stream created.');
|
||||
recorder = new Recorder(input);
|
||||
}
|
||||
|
||||
function sendVoice(){
|
||||
try {
|
||||
randomnumber= +new Date();
|
||||
var stream = client.send(blob, {name: randomnumber + "audio.wav" , size: blob.size});
|
||||
stream = client.send(final_transcript, {name: randomnumber + "asr.txt", size: final_transcript.length});
|
||||
stream = client.send(global_phrase, {name: randomnumber + "word.txt", size: global_phrase.length});
|
||||
stream = client.send(str_grm, {name: randomnumber + "grm.txt", size: str_grm.length});
|
||||
|
||||
console.log("streaming");
|
||||
|
||||
document.querySelector("#sendbtn").value = "Thanks for the contribution!";
|
||||
blob = null;
|
||||
localStorage.setItem("totalsamples" , (+localStorage.getItem("totalsamples"))+1 );
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
alert("You have disconnected. Please, restart the appplication.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
window.setTimeout(
|
||||
function(){
|
||||
document.querySelector("#divsendbtn").style.display = 'none';
|
||||
document.querySelector("#lblstatus").style.display = 'block';
|
||||
document.querySelector("#fox").style.display = 'block';
|
||||
document.querySelector("#mic").style.display = 'block';
|
||||
},
|
||||
1000);
|
||||
}
|
||||
|
||||
function startRecording() {
|
||||
recorder && recorder.record();
|
||||
console.log('Recording...');
|
||||
}
|
||||
|
||||
function stopRecording(button) {
|
||||
recorder && recorder.stop();
|
||||
console.log('Stopped recording.');
|
||||
// create WAV download link using audio data blob
|
||||
createUploadLink();
|
||||
recorder.clear();
|
||||
}
|
||||
|
||||
|
||||
function createUploadLink() {
|
||||
recorder && recorder.exportWAV(function(_blob) {
|
||||
blob = _blob;
|
||||
document.querySelector("#divsendbtn").style.display = 'block';
|
||||
document.querySelector("#sendbtn").value = "Submit";
|
||||
|
||||
// hide mic and thanks text
|
||||
document.querySelector("#mic").style.display = 'none';
|
||||
document.querySelector("#lblstatus").style.display = 'none';
|
||||
console.log('mediarecorder stopped');
|
||||
document.querySelector("#msgsamples").innerHTML = "You contributed with "+localStorage.getItem("totalsamples") +" samples so far!";
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function onendspeak(number)
|
||||
{
|
||||
console.log('starting')
|
||||
sr.start(); // Validation of sr.grammars occurs here
|
||||
startRecording();
|
||||
sr.onresult = function(event){
|
||||
recognizing = false;
|
||||
stopRecording();
|
||||
document.querySelector("#listening").style.display = 'none';
|
||||
document.querySelector("#fox").style.display = 'block';
|
||||
|
||||
final_transcript = '';
|
||||
// Assemble the transcript from the array of results
|
||||
for (var i = event.resultIndex; i < event.results.length; ++i) {
|
||||
if (event.results[i].isFinal) {
|
||||
console.log("recognition.onresult : isFinal");
|
||||
final_transcript += event.results[i][0].transcript;
|
||||
}
|
||||
}
|
||||
|
||||
var e = document.createElement("audio");
|
||||
e.src = "camcorder_end.opus";
|
||||
e.setAttribute("autoplay", "true");
|
||||
changelabel("Thank you! <br> Tap the microphone to say the next sequence.");
|
||||
};
|
||||
}
|
||||
|
||||
function say(phrase,file){
|
||||
|
||||
if (recognizing){
|
||||
return;
|
||||
}
|
||||
|
||||
document.querySelector("#divsendbtn").style.display = 'none';
|
||||
|
||||
var number = "(";
|
||||
for (i = 0; i<=9; i++){
|
||||
|
||||
if (i == 3)
|
||||
number = number.concat(") ")
|
||||
|
||||
var rnd = Math.random().toString().substring(2,3);
|
||||
var number = number.concat( rnd );
|
||||
|
||||
}
|
||||
phrase = phrase.concat(number);
|
||||
global_phrase = number;
|
||||
|
||||
recognizing = true;
|
||||
var e = document.createElement("audio");
|
||||
e.src = "camcorder_start.opus";
|
||||
e.setAttribute("autoplay", "true");
|
||||
e.addEventListener("ended", function(){
|
||||
changelabel(phrase);
|
||||
document.querySelector("#listening").style.display = 'block';
|
||||
document.querySelector("#fox").style.display = 'none';
|
||||
onendspeak(number);
|
||||
});
|
||||
}
|
||||
|
||||
function changelabel(str){
|
||||
document.querySelector("#lblstatus").style.display = 'block';
|
||||
document.querySelector("#lblstatus").innerHTML = str;
|
||||
}
|
||||
|
||||
function load(){
|
||||
checkoptin();
|
||||
|
||||
speakbtn.onclick = function (){
|
||||
|
||||
if (offline)
|
||||
alert("You have disconnected. Please, restart the appplication.");
|
||||
else
|
||||
say("Say this phone number:<br>");
|
||||
}
|
||||
|
||||
agreebtn.onclick = function (){
|
||||
localStorage.setItem("optin" , "1");;
|
||||
checkoptin();
|
||||
}
|
||||
|
||||
cancelbtn.onclick = function (){
|
||||
document.querySelector("#divsendbtn").style.display = 'none';
|
||||
document.querySelector("#mic").style.display = 'block';
|
||||
document.querySelector("#lblstatus").style.display = 'block';
|
||||
}
|
||||
|
||||
sendbtn.onclick = function (){
|
||||
if (blob != null)
|
||||
sendVoice();
|
||||
}
|
||||
|
||||
sr = new SpeechRecognition();
|
||||
sr.lang ="en-US";
|
||||
var sgl = new SpeechGrammarList();
|
||||
sgl.addFromString(str_grm ,1);
|
||||
sr. grammars = sgl;
|
||||
}
|
||||
|
||||
function checkoptin(){
|
||||
if (localStorage.getItem("optin") == "1"){
|
||||
document.querySelector("#optincard").style.display = 'none';
|
||||
document.querySelector("#maindiv").style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
document.body.onload = function () {
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in a new issue