Esse commit está contido em:
hesamsagha
2016-11-30 19:27:48 +01:00
commit eea2a61003
106 arquivos alterados com 3058 adições e 0 exclusões
+14
Ver Arquivo
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
+42
Ver Arquivo
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>er</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
+12
Ver Arquivo
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
+8
Ver Arquivo
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
+4
Ver Arquivo
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="er">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="java-output-path" value="/er/build/classes"/>
<property name="context-root" value="er"/>
</wb-module>
</project-modules>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v7.0"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
@@ -0,0 +1 @@
Window
+117
Ver Arquivo
@@ -0,0 +1,117 @@
<html>
<!-- script src='main2.js'></script>
<!-- script src='recorder.js'></script -->
<script type="text/javascript">
function preparevals(){
var myForm=document.chbxfrm;
var dims = "";
if(myForm.ars_chbx.checked)
dims+="arousal,";
if(myForm.val_chbx.checked)
dims+="valence,";
if(myForm.age_chbx.checked)
dims+="age,";
if(myForm.gen_chbx.checked)
dims+="gender,";
if(myForm.prsn_chbx.checked)
dims+="big5o,big5c,big5e,big5a,big5n,";
if(myForm.sent_chbx.checked)
dims+="sentiment,";
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", "dims");
input.setAttribute("value", dims.substring(0,dims.length-1));
document.getElementById("idfrmhot").appendChild(input);
var inputTime = document.createElement("input");
inputTime.setAttribute("type", "hidden");
inputTime.setAttribute("name", "timing");
if(myForm.sent_chbx.checked && !myForm.asr_chbx.checked){
alert("To run sentiment analysis, you should ckeck ASR!")
}
if(myForm.asr_chbx.checked || myForm.sent_chbx.checked){
inputTime.setAttribute("value","asr");
}else{
inputTime.setAttribute("value","-1,-1");
}
//alert("I am here");
document.getElementById("idfrmhot").appendChild(inputTime);
var myupForm=document.upform;
var filename = myupForm.file.value;
var s = filename.split("\\");
var fs = s[s.length-1];
var inputURL = document.createElement("input");
inputURL.setAttribute("type", "hidden");
inputURL.setAttribute("name", "url");
inputURL.setAttribute("value",fs);
document.getElementById("idfrmhot").appendChild(inputURL);
//alert(dims);
//return false;
var myupForm=document.upform;
myupForm.uploadedtext.value=""
return true;
}
function fileuploaded() {
var myupForm=document.upform;
myupForm.uploadedtext.value="File uploaded!"
//document.getElementById("idfrmhot").appendChild(inputURL);
}
</script>
<body>
<h1>Upload an audio file for processing</h1>
<iframe width="0" height="0" name="dummyframe" id="dummyframe" onload="return fileuploaded()"></iframe>
<form action="aer/upload" method="post" name="upform"
enctype="multipart/form-data" target="dummyframe" >
Select a file : <input type="file" name="file" size="45" />
<input type="submit" value="Upload It" />
<input type="text" name="uploadedtext" value="" readonly>
</form>
<br>
<!-- input type="button" value="Record audio" onclick="return toggleRecording(this);"-->
<form name="chbxfrm" >
<input type="checkbox" name="ars_chbx" checked> Arousal
<input type="checkbox" name="val_chbx" checked> Valence
<input type="checkbox" name="age_chbx" value="true" checked> Age
<input type="checkbox" name="gen_chbx" value="true" checked> Gender
<input type="checkbox" name="prsn_chbx" value="true" checked> Big 5 Personality traits
<input type="checkbox" name="asr_chbx" value="true" checked> ASR
<input type="checkbox" name="sent_chbx" value="true" checked> Sentiment
</form>
<br>
<form action="aer/getdims" method="get" id="idfrmhot" name="frmhot"
enctype="multipart/form-data" onsubmit="return preparevals()">
<!-- input name="dims">hi</input-->
<!-- input name="url"></input -->
<!-- input name="timing"></input-->
<!-- input type="hidden" name="url" value="foo" / -->
<!-- input type="hidden" name="timing" value="-1,-1" / -->
<input type="submit" value="Show the magic!" />
</form>
</body>
</html>
+3
Ver Arquivo
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
+66
Ver Arquivo
@@ -0,0 +1,66 @@
var onFail = function(e) {
//alert("I am Failed");
console.log('Rejected!', e);
};
var onSuccess = function(s) {
//alert("I am Successed");
var context = new webkitAudioContext();
var mediaStreamSource = context.createMediaStreamSource(s);
recorder = new Recorder(mediaStreamSource);
recorder.record();
// audio loopback
// mediaStreamSource.connect(context.destination);
};
function stopRecording() {
recorder.stop();
alert("SSSS");
recorder.exportWAV(function(s) {
audio.src = window.URL.createObjectURL(s);
alert(audio.src);
});
}
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
var recorder;
var audio = document.querySelector('audio');
function toggleRecording( e ) {
alert("instop");
if (e.classList.contains("recording")) {
alert("instop");
stopRecording();
e.classList.remove("recording");
// stop recording
//audioRecorder.stop();
//a/udioRecorder.getBuffers( gotBuffers );
//saveAudio();
} else {
// start recording
alert("instart");
startRecording();
e.classList.add("recording");
/*window.addEventListener('load', initAudio );
alert("I am here");
if (!audioRecorder)
return;
audioRecorder.clear();
audioRecorder.record();*/
}
}
function startRecording() {
if (navigator.getUserMedia) {
navigator.getUserMedia({audio: true}, onSuccess, onFail);
} else {
console.log('navigator.getUserMedia not present');
}
}
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
+219
Ver Arquivo
@@ -0,0 +1,219 @@
(function(window){
var WORKER_PATH = 'recorderWorker.js';
var Recorder = function(source, cfg){
var config = cfg || {};
var bufferLen = config.bufferLen || 4096;
this.context = source.context;
this.node = this.context.createJavaScriptNode(bufferLen, 2, 2);
var worker = new Worker(config.workerPath || WORKER_PATH);
worker.postMessage({
command: 'init',
config: {
sampleRate: this.context.sampleRate
}
});
var recording = false,
currCallback;
this.node.onaudioprocess = function(e){
if (!recording) return;
worker.postMessage({
command: 'record',
buffer: [
e.inputBuffer.getChannelData(0),
e.inputBuffer.getChannelData(1)
]
});
};
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);
//ADDITIONAL JS recorderWorker.js
var recLength = 0,
recBuffersL = [],
recBuffersR = [],
sampleRate;
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;
}
function record(inputBuffer){
recBuffersL.push(inputBuffer[0]);
recBuffersR.push(inputBuffer[1]);
recLength += inputBuffer[0].length;
}
function exportWAV(type){
var bufferL = mergeBuffers(recBuffersL, recLength);
var bufferR = mergeBuffers(recBuffersR, recLength);
var interleaved = interleave(bufferL, bufferR);
var dataview = encodeWAV(interleaved);
var audioBlob = new Blob([dataview], { type: type });
this.postMessage(audioBlob);
}
function getBuffer() {
var buffers = [];
buffers.push( mergeBuffers(recBuffersL, recLength) );
buffers.push( mergeBuffers(recBuffersR, recLength) );
this.postMessage(buffers);
}
function clear(){
recLength = 0;
recBuffersL = [];
recBuffersR = [];
}
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');
/* file length */
view.setUint32(4, 32 + 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, 2, 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, 4, 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;
}
Arquivo binário não exibido.
+20
Ver Arquivo
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<welcome-file-list>
<welcome-file>er</welcome-file>
</welcome-file-list>
<display-name>er</display-name>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.opensmile.maven.MyApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/aer/*</url-pattern>
</servlet-mapping>
</web-app>
+47
Ver Arquivo
@@ -0,0 +1,47 @@
function RecordAudio(stream, cfg) {
var config = cfg || {};
var bufferLen = config.bufferLen || 4096;
var numChannels = config.numChannels || 2;
this.context = stream.context;
var recordBuffers = [];
var recording = false;
this.node = (this.context.createScriptProcessor ||
this.context.createJavaScriptNode).call(this.context,
bufferLen, numChannels, numChannels);
stream.connect(this.node);
this.node.connect(this.context.destination);
this.node.onaudioprocess = function(e) {
if (!recording) return;
for (var i = 0; i < numChannels; i++) {
if (!recordBuffers[i]) recordBuffers[i] = [];
recordBuffers[i].push.apply(recordBuffers[i], e.inputBuffer.getChannelData(i));
}
};
this.getData = function() {
var tmp = recordBuffers;
recordBuffers = [];
return tmp; // returns an array of array containing data from various channels
};
}
var recorder;
function toggleRecording( e ) {
if (e.classList.contains("recording")) {
alert("instop");
recorder.stop();
var recordedData = recorder.getData();
e.classList.remove("recording");
} else {
recorder = new RecordAudio(userMedia);
alert("started");
recorder.start();
e.classList.add("recording");
}
}
+64
Ver Arquivo
@@ -0,0 +1,64 @@
function RecordAudio(stream, cfg) {
var config = cfg || {};
var bufferLen = config.bufferLen || 4096;
var numChannels = config.numChannels || 2;
this.context = stream.context;
var recordBuffers = [];
var recording = false;
this.node = (this.context.createScriptProcessor ||
this.context.createJavaScriptNode).call(this.context,
bufferLen, numChannels, numChannels);
stream.connect(this.node);
this.node.connect(this.context.destination);
this.node.onaudioprocess = function(e) {
if (!recording) return;
for (var i = 0; i < numChannels; i++) {
if (!recordBuffers[i]) recordBuffers[i] = [];
recordBuffers[i].push.apply(recordBuffers[i], e.inputBuffer.getChannelData(i));
}
};
this.getData = function() {
var tmp = recordBuffers;
recordBuffers = [];
return tmp; // returns an array of array containing data from various channels
};
/* this.start() = function() {
recording = true;
};
this.stop() = function() {
recording = false;
};*/
}
var recorder;
function toggleRecording( e ) {
if (e.classList.contains("recording")) {
alert("instop");
recorder.stop();
var recordedData = recorder.getData();
e.classList.remove("recording");
// stop recording
//audioRecorder.stop();
//a/udioRecorder.getBuffers( gotBuffers );
//saveAudio();
} else {
recorder = new RecordAudio(userMedia);
alert("started");
recorder.start();
e.classList.add("recording");
/*window.addEventListener('load', initAudio );
alert("I am here");
if (!audioRecorder)
return;
audioRecorder.clear();
audioRecorder.record();*/
}
}
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
+65
Ver Arquivo
@@ -0,0 +1,65 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>er</groupId>
<artifactId>er</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webXml>WebContent/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20151123</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.jvnet.mimepull</groupId>
<artifactId>mimepull</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>
</project>
+2
Ver Arquivo
@@ -0,0 +1,2 @@
REST_FILES=/media/sag/DATA/eclipse_workspace/downloadedFiles2/
REST_OPENSMILE=/home/sag/work/ME/platform_smilextract2/
+18
Ver Arquivo
@@ -0,0 +1,18 @@
package com.opensmile.maven;
import java.io.File;
import org.json.JSONObject;
public abstract class Classifier {
public String arg="";
public logger logger_instance;
String configFile = "";
String onyxentity = "";
String intype="";
public abstract boolean configure(JSONObject json);
public abstract JSONObject classify(String inputString);
public String getInType(){
return intype;
}
}
+38
Ver Arquivo
@@ -0,0 +1,38 @@
package com.opensmile.maven;
import java.io.File;
import org.json.JSONObject;
public abstract class Classifier {
public String arg="";
public logger logger_instance;
String configFile = "";
String onyxentity = "";
String intype="";
public abstract boolean configure(JSONObject json);
public abstract JSONObject classify(String inputString);
public String getInType(){
return intype;
}
}
/* SAMPLE INPUT JSON CONF
{
"configs":[
{
"classifier":"opensmilesvm",
"config":"IS09_emotion_A.conf",
"onyxentity":"emovoc:arousal"
},{
"classifier":"opensmilesvm",
"config":"IS09_emotion_V.conf",
"onyxentity":"emovoc:pleasure"
}
]}
SAMPLE OUTPUT JSON RESULTS
{
"emovoc:pleasure":" 1.00",
"confidence":0.2
}
*/
@@ -0,0 +1,30 @@
package com.opensmile.maven;
import org.json.JSONObject;
public class ClassifierFactory {
public ClassifierFactory() {
}
static public Classifier createClassifier(String name,logger logger_instance){
if(name.compareTo("opensmilesvm")==0){
Classifier c = new openSMILEclassifier();
c.logger_instance = logger_instance;
}
return null;
}
public static Classifier createClassifier(JSONObject jo, logger logger_instance) {
Classifier c;
switch(jo.getString("classifier")){
case "opensmilesvm":
c = new openSMILEclassifier();
c.logger_instance = logger_instance;
return c;
case "bash":
c = new bashClassifier();
c.logger_instance = logger_instance;
return c;
}
return null;
}
}
+757
Ver Arquivo
@@ -0,0 +1,757 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.glassfish.jersey.server.ResourceConfig;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@Path("")
public class EmoRecService extends ResourceConfig {
logger logger_instance = new logger((new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")).format(Calendar.getInstance().getTime()).replace("/", "_").replace(":", "_").replace(" ", "_"));
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail)// ,
{
String uploadedFileLocation = paths.FileDirectory
+ fileDetail.getFileName();
writeToFile(uploadedInputStream, uploadedFileLocation);
String output = "File uploaded to : " + uploadedFileLocation;
return Response.status(200).entity(output).build();
}
@Path("/")
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response nothing(){
return(Response.status(200).entity(genderateHelp()).build());
}
boolean DOCKER = false;
@Path("/getdims")
@GET
@Produces("application/json")
public Response getdims(@QueryParam("dims") String dim,
@QueryParam("url") String url,
@DefaultValue("") @QueryParam("json") String jsonfile,
@DefaultValue("-1,-1") @QueryParam("timing") String time,
@DefaultValue("false") @QueryParam("mobile") String mobilemode,
@DefaultValue("") @QueryParam("texts") String texts)
throws JSONException {
logger_instance.write(1,"Inside getdims");
if(dim==null){
return(Response.status(200).entity(genderateHelp()).build());
}
dim = dim.toLowerCase();
File file = wget(url);// wget command to retrieve the video content
logger_instance.write(1,"URL downloaded to "+file.getAbsolutePath());
String extension = "";
int i = file.getName().lastIndexOf('.');
String[] splitedTexts =null;
if(texts.length()>0){
splitedTexts = texts.split(";");
}
if (i >= 0) {
extension = file.getName().substring(i + 1);
}
File wavFile;
wavFile = convertToWave(file);
logger_instance.write(1,"File converted to wav: "+wavFile.getAbsolutePath());
String[] times = time.split(";");
String asrname = "____________________";
String text="";
boolean doingASR = false;
boolean asr_error=false;
String temp_text = "";
if (times[0].toLowerCase().compareTo("asr")==0 || times[0].toLowerCase().compareTo("asr_word")==0){
if(DOCKER){
return Response.status(200).entity("ASR and Sentiment are not available for the Docker version").build();
}
logger_instance.write(1, " Perform ASR");
doingASR = true;
try {
double audioDuration = getAudioDuration(wavFile.getAbsolutePath());
String tim = "";
double asraudioleng = 120;//audioDuration;
for(double startTime = 0;startTime < audioDuration;startTime+=asraudioleng){
double ending = Math.min(startTime+asraudioleng,audioDuration);
double duration = ending - startTime;
logger_instance.write(1, " Perform ASR, time:"+ startTime + " - " + ending);
if(duration < .5)
break;
File cuttedaudioasr = cutAudio(wavFile, String.valueOf(startTime), String.valueOf(duration), 100000+startTime);
JSONArray jasr = performASR2(cuttedaudioasr.getAbsolutePath());
if(jasr.length()==0){
if(startTime==0 && startTime+asraudioleng>=audioDuration){//only one slice
temp_text="NO TEXT IS DETECTED!";
tim = "-1,-1";
break;
}
else
continue;
}
else{
ArrayList<String> temp_texta= new ArrayList<String>();
ArrayList<Integer> start_time= new ArrayList<Integer>();
ArrayList<Integer> end_time=new ArrayList<Integer>();
for(int iw = 0;iw<jasr.length();iw++){
if(jasr.getJSONObject(iw).getString("word").compareTo("<s>")!=0 && jasr.getJSONObject(iw).getString("word").compareTo("</s>")!=0){
temp_texta.add(jasr.getJSONObject(iw).getString("word"));
start_time.add(jasr.getJSONObject(iw).getInt("start"));
end_time.add(jasr.getJSONObject(iw).getInt("end"));
}
}
if(times[0].toLowerCase().compareTo("asr_word")==0){
for(int iw = 0;iw<temp_texta.size();iw++){
if(temp_texta.get(iw).compareTo(".")==0)continue;
double vst=start_time.get(iw).doubleValue()/10000000+startTime;
double ven=end_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)vst).toString()+","+((Double)ven).toString()+";";
temp_text+=temp_texta.get(iw)+";";
}
}
else{
boolean start = true;
boolean prevDot = false;
for(int iw = 0;iw<temp_texta.size();iw++){
if(temp_texta.get(iw).compareTo(".")==0){
if(prevDot)continue;//double dots
double v=start_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)v).toString()+";";
temp_text+=";";
start=true;
prevDot = true;
continue;
}
prevDot = false;
if(start==true){
double v = start_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)v).toString()+",";
start=false;
}
temp_text+= temp_texta.get(iw)+" ";
if(iw==temp_texta.size()-1 && !temp_text.endsWith(".")){
temp_text+=";";
double v=end_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)v).toString()+";";
}
}
}
}
}
if(tim.endsWith(";"))
tim = tim.substring(0, tim.length()-1);
if(temp_text.endsWith(";"))
temp_text = temp_text.substring(0, temp_text.length()-1);
splitedTexts = temp_text.split(";");
times = tim.split(";");
} catch (IOException e) {
splitedTexts="IOException during ASR".split(",");
logger_instance.write(1, "IOException during ASR"+e.getMessage());
asr_error = true;
dim=dim.replace("sentiment,", "").replace(",sentiment","").replace("sentiment", "");
times = "-1,-1".split(";");
} catch (InterruptedException e) {
e.printStackTrace();
return Response.status(200).entity("InterruptedException during ASR").build();
}
}
if(mobilemode.compareTo("true")==0){
times=new String[]{"-1,-1"};
if(doingASR)
splitedTexts=new String[]{temp_text.replace("%20", " ").replace(";",". ")};
}
String finalJSONString = "[";
String[] dims = dim.split(",");
ArrayList<Classifier> clf = new ArrayList<Classifier>();
logger_instance.write(1,"Loading config.json from :" + paths.getVar("REST_OPENSMILE")+ "configs.json");
JSONObject jo = loadJsonObject(paths.getVar("REST_OPENSMILE")+ "configs.json");
logger_instance.write(1,"JSON is loaded: "+ jo.toString());
JSONArray ja = jo.getJSONArray("configs");
logger_instance.write(1, "dims:" + dims.length);
for (int d = 0; d < dims.length; d++) {
if((dims[d].toLowerCase().compareTo("sentiment")==0 || dims[d].toLowerCase().compareTo("asr")==0) && DOCKER){
return Response.status(200).entity("ASR and Sentiment are not available for the Docker version").build();
}
boolean added = false;
for(int j = 0;j<ja.length();j++){
if(((JSONObject)ja.get(j)).getString("id").compareTo(dims[d].toLowerCase())==0){
Classifier c = ClassifierFactory.createClassifier((JSONObject) ja
.get(j),logger_instance);
c.configure((JSONObject) ja.get(j));
clf.add(c);
added = true;break;
}
}
if(!added)
return Response.status(200).entity(dims[d] +" is not supported!").build();/**/
}
logger_instance.write(1,""+ clf.size()+ " classifiers are added");
ExecutorService exec = Executors.newFixedThreadPool(times.length);
logger_instance.write(1, "times:" + times.length);
for (i = 0; i < times.length; i++) {
String[] timesplit = times[i].split(",");
String duration = "-1";
if(timesplit[1].trim().compareTo("-1")==0)
duration = "-1";
else{
Double d = Double.valueOf(timesplit[1].trim()) - Double.valueOf(timesplit[0].trim());
duration = d.toString();
}
final File cuttedAudio = cutAudio(wavFile, timesplit[0],
duration, i);
final JSONArray jaresult = new JSONArray();
final CountDownLatch latch = new CountDownLatch(clf.size());
final String[] textttt = splitedTexts;
final boolean da = doingASR;
final int iiii = i;
for (final Classifier cl : clf) {
exec.submit(new Runnable() {
@Override
public void run() {
logger_instance.write(1, " run ");
try {
if(cl.getInType().compareTo("audio")==0)
jaresult.put(cl.classify(cuttedAudio.getAbsolutePath()));
else if(cl.getInType().compareTo("text")==0 && da==true && textttt!=null)
jaresult.put(cl.classify(textttt[iiii].replace(" " , "_")));
} catch (Exception e) {
logger_instance.write(1, " classification exception: " + e.getMessage());
e.printStackTrace();
} finally {
}
logger_instance.write(1, " finished ");
latch.countDown();
}
});
}
logger_instance.write(1, " latch wait ");
try {
latch.await();
} catch (InterruptedException e) {
logger_instance.write(1, " latch InterruptedException: " + e.getMessage());
e.printStackTrace();
}
// create json
JSONObject jsonobj = write2JSON(url, i, timesplit[0], timesplit[1],
jaresult);
if(doingASR){
JSONObject j = new JSONObject();
j.put("ASR", "Powered by Phonexia");
int n = jsonobj.getJSONArray("analysis").length();
jsonobj.getJSONArray("analysis").put(n,j );
}
if(splitedTexts!=null && splitedTexts.length>0 && i<splitedTexts.length){
jsonobj.put("Text",splitedTexts[i]);
}
if (jsonfile.compareTo("") != 0) {// add to already existed json
JSONObject jsonobjexist = loadJsonObject(jsonfile);
jsonobj = mergeJSONs(jsonobjexist, jsonobj);
}
finalJSONString += jsonobj.toString(4) + "\n";
if(i!=times.length-1)
finalJSONString += ",";
System.out.println(""+i +"/"+times.length + " processed.");
}
finalJSONString+="]";
if(mobilemode.compareTo("true")==0){
finalJSONString=finalJSONString.substring(1, finalJSONString.length()-2);
}
//deleting
String[] ss =asrname.split("/");
final String ffnn = ss[ss.length-1];
ss = file.toString().split("/");
final String wwfn = ss[ss.length-1];
final File folder = new File(paths.FileDirectory);
final File[] files = folder.listFiles( new FilenameFilter() {
@Override
public boolean accept( final File dir,
final String name ) {
boolean b = false;
b = b | name.startsWith(ffnn+"." );
b = b | name.startsWith(wwfn+"." );
return b;
}
} );
for ( final File ffile : files ) {
if ( !ffile.delete() ) {
System.err.println( "Can't remove " + ffile.getAbsolutePath() );
}
}
return Response.status(200).entity(finalJSONString).build();
}
@Path("/getByConfig")
@GET
@Produces("application/json")
public Response getByConfig(@QueryParam("url") String url,
@DefaultValue("") @QueryParam("json") String jsonfile,
@DefaultValue("") @QueryParam("conf") String conffile,
@DefaultValue("-1,-1") @QueryParam("timing") String time,
@DefaultValue("") @QueryParam("texts") String texts)
throws JSONException {
File file = wget(url);// wget command to retrieve the video content
JSONObject jo = loadJsonObject(conffile);
JSONArray ja = jo.getJSONArray("configs");
ArrayList<Classifier> clf = new ArrayList<Classifier>();
for (int i = 0; i < ja.length(); i++) {
jo = ja.getJSONObject(i);
Classifier c = ClassifierFactory.createClassifier(jo
.getString("classifier"),logger_instance);
c.configure(jo);
clf.add(c);
}
String[] splitedTexts =null;
if(texts.length()>0){
splitedTexts = texts.split(";");
}
String extension = "";
int i = file.getName().lastIndexOf('.');
if (i >= 0) {
extension = file.getName().substring(i + 1);
}
File wavFile;
if (extension.toLowerCase().compareTo("wav") == 0) {
wavFile = file;
} else {
wavFile = convertToWave(file);
}
String[] times = time.split(";");
String finalJSONString = "";
ExecutorService exec = Executors.newFixedThreadPool(times.length);
for (i = 0; i < times.length; i++) {
String[] timesplit = times[i].split(",");
final File cuttedAudio = cutAudio(wavFile, timesplit[0],
timesplit[1], i);
final JSONArray jaresult = new JSONArray();
final CountDownLatch latch = new CountDownLatch(clf.size());
try {
for (final Classifier cl : clf) {
exec.submit(new Runnable() {
@Override
public void run() {
jaresult.put(cl.classify(cuttedAudio.getAbsolutePath()));
latch.countDown();
}
});
}
latch.await();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
JSONObject jsonobj = write2JSON(url, i, timesplit[0], timesplit[1],
jaresult);
if(i<splitedTexts.length){
jsonobj.put("Text",splitedTexts[i]);
}
if (jsonfile.compareTo("") != 0) {// add to already existed json
JSONObject jsonobjexist = loadJsonObject(jsonfile);
jsonobj = mergeJSONs(jsonobjexist, jsonobj);
}
finalJSONString += jsonobj.toString() + "\n";
}
exec.shutdown();
return Response.status(200).entity(finalJSONString).build();
}
@Path("/deleteFile")
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response deleteFile(@QueryParam("url") String url)
throws JSONException {
String[] urls = url.split("/");
final String output = urls[urls.length - 1];
File direct = new File(paths.FileDirectory);
String[] files = direct.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if (name.startsWith(output))
return true;
return false;
}
});
for (String s : files) {
File f = new File(paths.FileDirectory + s);
f.delete();
}
return Response.status(200).entity(files.length + " file(s) deleted!")
.build();
}
private JSONObject mergeJSONs(JSONObject jsonobjexist, JSONObject jsonobj) {
JSONObject jc = jsonobj.getJSONArray("@context").getJSONObject(0);
jsonobjexist.accumulate("@context", jc);
JSONObject janalysis = jsonobj.getJSONArray("analysis")
.getJSONObject(0);
JSONArray ja = jsonobjexist.getJSONArray("analysis");
ja.put(janalysis);
String emotionid = jsonobjexist.getJSONArray("entries")
.getJSONObject(0).getString("@id");
JSONObject jemotions = jsonobj.getJSONArray("entries").getJSONObject(0)
.getJSONArray("emotions").getJSONObject(0);
String idnew = jemotions.getString("@id");
String[] subid = idnew.split("#");
jemotions.put("@id", emotionid + "#" + subid[1]);
JSONArray jem2 = jsonobjexist.getJSONArray("entries").getJSONObject(0)
.getJSONArray("emotions");
jem2.put(jemotions);
return jsonobjexist;
}
private JSONArray performASR2(String wavefilename) throws IOException,InterruptedException{
String r = String.valueOf(Math.random()).replace(".", "_");
Process p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/asr_upload.sh "+wavefilename);
p.waitFor();
String line="";
String fullLine1="";
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine1=fullLine1+line;
JSONObject j = new JSONObject(fullLine1);
if(!(j.has("result") && j.getJSONObject("result").has("name")))
return null;//"ASR unsucessfull";
//running asr
p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/asr_run.sh "+wavefilename);
p.waitFor();
String fullLine3="";
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine3=fullLine3+line;
j = new JSONObject(fullLine3);
String id = j.getJSONObject("result").getJSONObject("info").getString("id");
while(true){
String fullLine4="";
Thread.sleep(2000);
p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/checkpending.sh "+id);
p.waitFor();
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine4=fullLine4+line;
j = new JSONObject(fullLine4);
if(!j.getJSONObject("result").has("info") || j.getJSONObject("result").getJSONObject("info").getString("state").compareTo("finished")==0)
break;
}
p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/asr_run.sh "+wavefilename);
p.waitFor();
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String fullLine5="";
while((line=in.readLine())!=null)
fullLine5=fullLine5+line;
j = new JSONObject(fullLine5);
JSONArray jo = j.getJSONObject("result").getJSONObject("one_best_result").getJSONArray("segmentation");
return jo;
}
private String performASR(String wavefilename) throws IOException,InterruptedException{
String r = String.valueOf(Math.random());
String fname = paths.FileDirectory + "asrout"+r+".tmp";
Process p = Runtime.getRuntime().exec(
"sh " + paths.SMILExtractDir +"asr_prep.sh "+ wavefilename);
p.waitFor();
FileReader f = new FileReader(wavefilename+".asrupload.txt");
BufferedReader br = new BufferedReader(f);
String aline;
boolean passed = false;
while((aline = br.readLine())!=null){
if(aline.contains("info format")){
passed = true;break;
}
}
br.close();
if (passed == false){
return "Posting file to ASR server failed";
}
f = new FileReader(wavefilename+".asrloc.txt");
String locationOnServer="";
br = new BufferedReader(f);
while((aline = br.readLine())!=null){
if(aline.contains("Location")){
locationOnServer = aline.substring(10);
break;
}
}
br.close();
boolean asr = false;
do{
Thread.sleep(2000);
p = Runtime.getRuntime().exec(
"sh " + paths.SMILExtractDir +"asr_get_res.sh "+ locationOnServer +" "+fname+".trans.txt");
p.waitFor();
f = new FileReader(fname+".trans.txt");
br = new BufferedReader(f);
while((aline = br.readLine())!=null){
if(aline.contains("result name=\"lvcsr\"")){
asr = true;br.close();
break;
}
}
}while(asr==false);
p = Runtime.getRuntime().exec(
"bash " + paths.SMILExtractDir + "asr_processor.sh " + fname + ".trans.txt " + wavefilename +" "+fname+".json");
p.waitFor();
return fname;
}
public static String readFile(String filename) throws IOException {
FileReader f = new FileReader(filename);
BufferedReader br = new BufferedReader(f);
String s = "";
String aline;
while((aline = br.readLine())!=null){
s = s + aline;
}
br.close();
return s;
}
static public JSONObject loadJsonObject(String jsonfilename) {
String line = "";
String jsonTxt = "";
BufferedReader is = null;
try {
is = new BufferedReader(new InputStreamReader(new FileInputStream(
jsonfilename)));
while ((line = is.readLine()) != null) {
jsonTxt += line;
}
is.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
JSONObject jsonobjexist = new JSONObject(jsonTxt);
return jsonobjexist;
}
private JSONObject write2JSON(String url, Integer index, String time,
String duration, JSONArray jaresult) {
JSONObject json = new JSONObject();
JSONArray jarray = new JSONArray();
JSONObject emovoc = new JSONObject();
emovoc.put("emovoc",
"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/emotionml/ns");
jarray.put(emovoc);
json.put("@context", jarray);
JSONArray janalysisarray = new JSONArray();
JSONObject janalysis = new JSONObject();
janalysis.put("@id", "me:SpeechAnalysis");
janalysis.put("@type", "onyx:EmotionAnalysis");
janalysis.put("onyx:usesEmotionModel", "emovoc:pad-dimensions");
janalysisarray.put(janalysis);
json.put("analysis", janalysisarray);
JSONArray jemotionsarray = new JSONArray();
JSONObject jemotion = new JSONObject();
jemotion.put("@id", "Entry" + index.toString() + "#time=" + time + ","
+ duration);
jemotion.put("prov:wasGeneratedBy", "me:SpeechAnalysis");
jemotion.put("onyx:hasEmotion", jaresult);
jemotionsarray.put(jemotion);
JSONObject jentry = new JSONObject();
jentry.put("emotions", jemotionsarray);
JSONArray jentriesarray = new JSONArray();
jentriesarray.put(jentry);
json.put("entries", jentriesarray);
return json;
}
private File cutAudio(File file, String startTime, String duration,
double d) {
File F = new File(file + "_p" + ((Double)d).toString() + ".wav");
try {
if (F.exists())
F.delete();
String durationStr = "";
if(startTime.startsWith(".")){
startTime = startTime+" ";
startTime = "0"+String.copyValueOf(startTime.toCharArray(), 0, startTime.length()-1);
}
if (startTime.compareTo("-1") == 0)
startTime = "0";
if (duration.compareTo("-1") != 0)
durationStr = " -t " + duration;
if(durationStr.startsWith(".")){
durationStr = durationStr+" ";
durationStr = "0"+String.copyValueOf(durationStr.toCharArray(), 0, durationStr.length()-1);
}
Process p = Runtime.getRuntime().exec(
"avconv" + " -i " + file + " -acodec copy " + " -ac 1 -ss "
+ startTime + // start
durationStr + // duration
" " + F.toString());
p.waitFor();
p = Runtime.getRuntime().exec(
"qwavheaderdump -q -F " + F.toString());// Fixing header
p.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
return F;
}
// convert av to .wav
private File convertToWave(File file) {
File F = new File(file.toString() + ".wav");
try {
if(F.exists())
F.delete();
//if (!F.exists())
Process p = Runtime.getRuntime().exec(
"avconv -loglevel quiet -i " + file + " -ac 1 -vn -f wav "
+ F.toString());
p.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
return F;
}
// download the resource
private File wget(String url) {
String[] urls = url.split("/");
String output = paths.FileDirectory + urls[urls.length - 1];
File F = new File(output);
try {
if (!F.exists()) {
Process p = Runtime.getRuntime().exec(
"wget -q -O " + output + " " + url);
p.waitFor();
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
F = null;
logger_instance.write(
1,
"wget exception: wget -q -O " + output + " " + url + "\n"
+ e.getMessage());
logger_instance.close();
}
return F;
}
private double getAudioDuration(String filename){
File file = new File(filename);
AudioInputStream audioInputStream;
float durationInSeconds = 0;
try {
audioInputStream = AudioSystem.getAudioInputStream(file);
AudioFormat format = audioInputStream.getFormat();
long audioFileLength = file.length();
int frameSize = format.getFrameSize();
float frameRate = format.getFrameRate();
durationInSeconds = (audioFileLength / (frameSize * frameRate));
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
}
return durationInSeconds;
}
private String genderateHelp(){
return "You have to set these parameters:\n" +
"getdims: desired dimentions separated by comma (arousal,valence,age,gender,sentiment)\n"+
" note that, to have sentiment, you should only have 'asr' (automatic speech recognition) in the 'timing' parameter.'\n"+
"url:the url of the video/audio or the name of the uploaded file\n"+
"timing: start and end of the segments (in seconds). start1,end1;start2,end2, OR asr\n"+
" when you choose 'asr', the audio file is segmented for each spoken sentence (useful for sentiment recognition) \n"+
"Example:\n"+
"http://mixedemotions.fim.uni-passau.de:8080/er/aer/getdims?dims=arousal,valence,gender,age&url=http://tv-download.dw.com/dwtv_video/flv/wikoe/wikoe20151114_wiruebli_sd_avc.mp4&timing=9,15;147,152"+
"\n\n"+
"To upload an audio/video file use curl:\n"+
"Windows: curl -v -H \"Content-Type:multipart/form-data\" --user meuser -i -X POST -F \"file=@D:\\path\\to\\sample.wav\" http://mixedemotions.fim.uni-passau.de:8080/er/aer/upload\n"+
"Linux: curl -v -H \"Content-Type:multipart/form-data\" --user meuser -i -X POST -F 'file=@./sample.wav' http://mixedemotions.fim.uni-passau.de:8080/er/aer/upload\n"+
"\n"+
"GUI interface: http://mixedemotions.fim.uni-passau.de:8080/er/FileUpload.html"
;
}
// save uploaded file to new location
private void writeToFile(InputStream uploadedInputStream,
String uploadedFileLocation) {
try {
OutputStream out = new FileOutputStream(new File(
uploadedFileLocation));
int read = 0;
byte[] bytes = new byte[1024];
out = new FileOutputStream(new File(uploadedFileLocation));
while ((read = uploadedInputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,757 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
import org.glassfish.jersey.server.ResourceConfig;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@Path("")
public class EmoRecService extends ResourceConfig {
logger logger_instance = new logger((new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")).format(Calendar.getInstance().getTime()).replace("/", "_").replace(":", "_").replace(" ", "_"));
@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.TEXT_PLAIN)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail)// ,
{
String uploadedFileLocation = paths.FileDirectory
+ fileDetail.getFileName();
writeToFile(uploadedInputStream, uploadedFileLocation);
String output = "File uploaded to : " + uploadedFileLocation;
return Response.status(200).entity(output).build();
}
@Path("/")
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response nothing(){
return(Response.status(200).entity(genderateHelp()).build());
}
boolean DOCKER = false;
@Path("/getdims")
@GET
@Produces("application/json")
public Response getdims(@QueryParam("dims") String dim,
@QueryParam("url") String url,
@DefaultValue("") @QueryParam("json") String jsonfile,
@DefaultValue("-1,-1") @QueryParam("timing") String time,
@DefaultValue("false") @QueryParam("mobile") String mobilemode,
@DefaultValue("") @QueryParam("texts") String texts)
throws JSONException {
logger_instance.write(1,"Inside getdims");
if(dim==null){
return(Response.status(200).entity(genderateHelp()).build());
}
dim = dim.toLowerCase();
File file = wget(url);// wget command to retrieve the video content
logger_instance.write(1,"URL downloaded to "+file.getAbsolutePath());
String extension = "";
int i = file.getName().lastIndexOf('.');
String[] splitedTexts =null;
if(texts.length()>0){
splitedTexts = texts.split(";");
}
if (i >= 0) {
extension = file.getName().substring(i + 1);
}
File wavFile;
wavFile = convertToWave(file);
logger_instance.write(1,"File converted to wav: "+wavFile.getAbsolutePath());
String[] times = time.split(";");
String asrname = "____________________";
String text="";
boolean doingASR = false;
boolean asr_error=false;
String temp_text = "";
if (times[0].toLowerCase().compareTo("asr")==0 || times[0].toLowerCase().compareTo("asr_word")==0){
if(DOCKER){
return Response.status(200).entity("ASR and Sentiment are not available for the Docker version").build();
}
logger_instance.write(1, " Perform ASR");
doingASR = true;
try {
double audioDuration = getAudioDuration(wavFile.getAbsolutePath());
String tim = "";
double asraudioleng = 120;//audioDuration;
for(double startTime = 0;startTime < audioDuration;startTime+=asraudioleng){
double ending = Math.min(startTime+asraudioleng,audioDuration);
double duration = ending - startTime;
logger_instance.write(1, " Perform ASR, time:"+ startTime + " - " + ending);
if(duration < .5)
break;
File cuttedaudioasr = cutAudio(wavFile, String.valueOf(startTime), String.valueOf(duration), 100000+startTime);
JSONArray jasr = performASR2(cuttedaudioasr.getAbsolutePath());
if(jasr.length()==0){
if(startTime==0 && startTime+asraudioleng>=audioDuration){//only one slice
temp_text="NO TEXT IS DETECTED!";
tim = "-1,-1";
break;
}
else
continue;
}
else{
ArrayList<String> temp_texta= new ArrayList<String>();
ArrayList<Integer> start_time= new ArrayList<Integer>();
ArrayList<Integer> end_time=new ArrayList<Integer>();
for(int iw = 0;iw<jasr.length();iw++){
if(jasr.getJSONObject(iw).getString("word").compareTo("<s>")!=0 && jasr.getJSONObject(iw).getString("word").compareTo("</s>")!=0){
temp_texta.add(jasr.getJSONObject(iw).getString("word"));
start_time.add(jasr.getJSONObject(iw).getInt("start"));
end_time.add(jasr.getJSONObject(iw).getInt("end"));
}
}
if(times[0].toLowerCase().compareTo("asr_word")==0){
for(int iw = 0;iw<temp_texta.size();iw++){
if(temp_texta.get(iw).compareTo(".")==0)continue;
double vst=start_time.get(iw).doubleValue()/10000000+startTime;
double ven=end_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)vst).toString()+","+((Double)ven).toString()+";";
temp_text+=temp_texta.get(iw)+";";
}
}
else{
boolean start = true;
boolean prevDot = false;
for(int iw = 0;iw<temp_texta.size();iw++){
if(temp_texta.get(iw).compareTo(".")==0){
if(prevDot)continue;//double dots
double v=start_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)v).toString()+";";
temp_text+=";";
start=true;
prevDot = true;
continue;
}
prevDot = false;
if(start==true){
double v = start_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)v).toString()+",";
start=false;
}
temp_text+= temp_texta.get(iw)+" ";
if(iw==temp_texta.size()-1 && !temp_text.endsWith(".")){
temp_text+=";";
double v=end_time.get(iw).doubleValue()/10000000+startTime;
tim+=((Double)v).toString()+";";
}
}
}
}
}
if(tim.endsWith(";"))
tim = tim.substring(0, tim.length()-1);
if(temp_text.endsWith(";"))
temp_text = temp_text.substring(0, temp_text.length()-1);
splitedTexts = temp_text.split(";");
times = tim.split(";");
} catch (IOException e) {
splitedTexts="IOException during ASR".split(",");
logger_instance.write(1, "IOException during ASR"+e.getMessage());
asr_error = true;
dim=dim.replace("sentiment,", "").replace(",sentiment","").replace("sentiment", "");
times = "-1,-1".split(";");
} catch (InterruptedException e) {
e.printStackTrace();
return Response.status(200).entity("InterruptedException during ASR").build();
}
}
if(mobilemode.compareTo("true")==0){
times=new String[]{"-1,-1"};
if(doingASR)
splitedTexts=new String[]{temp_text.replace("%20", " ").replace(";",". ")};
}
String finalJSONString = "[";
String[] dims = dim.split(",");
ArrayList<Classifier> clf = new ArrayList<Classifier>();
logger_instance.write(1,"Loading config.json from :" + paths.getVar("REST_OPENSMILE")+ "configs.json");
JSONObject jo = loadJsonObject(paths.getVar("REST_OPENSMILE")+ "configs.json");
logger_instance.write(1,"JSON is loaded: "+ jo.toString());
JSONArray ja = jo.getJSONArray("configs");
logger_instance.write(1, "dims:" + dims.length);
for (int d = 0; d < dims.length; d++) {
if((dims[d].toLowerCase().compareTo("sentiment")==0 || dims[d].toLowerCase().compareTo("asr")==0) && DOCKER){
return Response.status(200).entity("ASR and Sentiment are not available for the Docker version").build();
}
boolean added = false;
for(int j = 0;j<ja.length();j++){
if(((JSONObject)ja.get(j)).getString("id").compareTo(dims[d].toLowerCase())==0){
Classifier c = ClassifierFactory.createClassifier((JSONObject) ja
.get(j),logger_instance);
c.configure((JSONObject) ja.get(j));
clf.add(c);
added = true;break;
}
}
if(!added)
return Response.status(200).entity(dims[d] +" is not supported!").build();/**/
}
logger_instance.write(1,""+ clf.size()+ " classifiers are added");
ExecutorService exec = Executors.newFixedThreadPool(times.length);
logger_instance.write(1, "times:" + times.length);
for (i = 0; i < times.length; i++) {
String[] timesplit = times[i].split(",");
String duration = "-1";
if(timesplit[1].trim().compareTo("-1")==0)
duration = "-1";
else{
Double d = Double.valueOf(timesplit[1].trim()) - Double.valueOf(timesplit[0].trim());
duration = d.toString();
}
final File cuttedAudio = cutAudio(wavFile, timesplit[0],
duration, i);
final JSONArray jaresult = new JSONArray();
final CountDownLatch latch = new CountDownLatch(clf.size());
final String[] textttt = splitedTexts;
final boolean da = doingASR;
final int iiii = i;
for (final Classifier cl : clf) {
exec.submit(new Runnable() {
@Override
public void run() {
logger_instance.write(1, " run ");
try {
if(cl.getInType().compareTo("audio")==0)
jaresult.put(cl.classify(cuttedAudio.getAbsolutePath()));
else if(cl.getInType().compareTo("text")==0 && da==true && textttt!=null)
jaresult.put(cl.classify(textttt[iiii].replace(" " , "_")));
} catch (Exception e) {
logger_instance.write(1, " classification exception: " + e.getMessage());
e.printStackTrace();
} finally {
}
logger_instance.write(1, " finished ");
latch.countDown();
}
});
}
logger_instance.write(1, " latch wait ");
try {
latch.await();
} catch (InterruptedException e) {
logger_instance.write(1, " latch InterruptedException: " + e.getMessage());
e.printStackTrace();
}
// create json
JSONObject jsonobj = write2JSON(url, i, timesplit[0], timesplit[1],
jaresult);
if(doingASR){
JSONObject j = new JSONObject();
j.put("ASR", "Powered by Phonexia");
int n = jsonobj.getJSONArray("analysis").length();
jsonobj.getJSONArray("analysis").put(n,j );
}
if(splitedTexts!=null && splitedTexts.length>0 && i<splitedTexts.length){
jsonobj.put("Text",splitedTexts[i]);
}
if (jsonfile.compareTo("") != 0) {// add to already existed json
JSONObject jsonobjexist = loadJsonObject(jsonfile);
jsonobj = mergeJSONs(jsonobjexist, jsonobj);
}
finalJSONString += jsonobj.toString(4) + "\n";
if(i!=times.length-1)
finalJSONString += ",";
System.out.println(""+i +"/"+times.length + " processed.");
}
finalJSONString+="]";
if(mobilemode.compareTo("true")==0){
finalJSONString=finalJSONString.substring(1, finalJSONString.length()-2);
}
//deleting
String[] ss =asrname.split("/");
final String ffnn = ss[ss.length-1];
ss = file.toString().split("/");
final String wwfn = ss[ss.length-1];
final File folder = new File(paths.FileDirectory);
final File[] files = folder.listFiles( new FilenameFilter() {
@Override
public boolean accept( final File dir,
final String name ) {
boolean b = false;
b = b | name.startsWith(ffnn+"." );
b = b | name.startsWith(wwfn+"." );
return b;
}
} );
for ( final File ffile : files ) {
if ( !ffile.delete() ) {
System.err.println( "Can't remove " + ffile.getAbsolutePath() );
}
}
return Response.status(200).entity(finalJSONString).build();
}
@Path("/getByConfig")
@GET
@Produces("application/json")
public Response getByConfig(@QueryParam("url") String url,
@DefaultValue("") @QueryParam("json") String jsonfile,
@DefaultValue("") @QueryParam("conf") String conffile,
@DefaultValue("-1,-1") @QueryParam("timing") String time,
@DefaultValue("") @QueryParam("texts") String texts)
throws JSONException {
File file = wget(url);// wget command to retrieve the video content
JSONObject jo = loadJsonObject(conffile);
JSONArray ja = jo.getJSONArray("configs");
ArrayList<Classifier> clf = new ArrayList<Classifier>();
for (int i = 0; i < ja.length(); i++) {
jo = ja.getJSONObject(i);
Classifier c = ClassifierFactory.createClassifier(jo
.getString("classifier"),logger_instance);
c.configure(jo);
clf.add(c);
}
String[] splitedTexts =null;
if(texts.length()>0){
splitedTexts = texts.split(";");
}
String extension = "";
int i = file.getName().lastIndexOf('.');
if (i >= 0) {
extension = file.getName().substring(i + 1);
}
File wavFile;
if (extension.toLowerCase().compareTo("wav") == 0) {
wavFile = file;
} else {
wavFile = convertToWave(file);
}
String[] times = time.split(";");
String finalJSONString = "";
ExecutorService exec = Executors.newFixedThreadPool(times.length);
for (i = 0; i < times.length; i++) {
String[] timesplit = times[i].split(",");
final File cuttedAudio = cutAudio(wavFile, timesplit[0],
timesplit[1], i);
final JSONArray jaresult = new JSONArray();
final CountDownLatch latch = new CountDownLatch(clf.size());
try {
for (final Classifier cl : clf) {
exec.submit(new Runnable() {
@Override
public void run() {
jaresult.put(cl.classify(cuttedAudio.getAbsolutePath()));
latch.countDown();
}
});
}
latch.await();
} catch (Exception e) {
e.printStackTrace();
} finally {
}
JSONObject jsonobj = write2JSON(url, i, timesplit[0], timesplit[1],
jaresult);
if(i<splitedTexts.length){
jsonobj.put("Text",splitedTexts[i]);
}
if (jsonfile.compareTo("") != 0) {// add to already existed json
JSONObject jsonobjexist = loadJsonObject(jsonfile);
jsonobj = mergeJSONs(jsonobjexist, jsonobj);
}
finalJSONString += jsonobj.toString() + "\n";
}
exec.shutdown();
return Response.status(200).entity(finalJSONString).build();
}
@Path("/deleteFile")
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response deleteFile(@QueryParam("url") String url)
throws JSONException {
String[] urls = url.split("/");
final String output = urls[urls.length - 1];
File direct = new File(paths.FileDirectory);
String[] files = direct.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if (name.startsWith(output))
return true;
return false;
}
});
for (String s : files) {
File f = new File(paths.FileDirectory + s);
f.delete();
}
return Response.status(200).entity(files.length + " file(s) deleted!")
.build();
}
private JSONObject mergeJSONs(JSONObject jsonobjexist, JSONObject jsonobj) {
JSONObject jc = jsonobj.getJSONArray("@context").getJSONObject(0);
jsonobjexist.accumulate("@context", jc);
JSONObject janalysis = jsonobj.getJSONArray("analysis")
.getJSONObject(0);
JSONArray ja = jsonobjexist.getJSONArray("analysis");
ja.put(janalysis);
String emotionid = jsonobjexist.getJSONArray("entries")
.getJSONObject(0).getString("@id");
JSONObject jemotions = jsonobj.getJSONArray("entries").getJSONObject(0)
.getJSONArray("emotions").getJSONObject(0);
String idnew = jemotions.getString("@id");
String[] subid = idnew.split("#");
jemotions.put("@id", emotionid + "#" + subid[1]);
JSONArray jem2 = jsonobjexist.getJSONArray("entries").getJSONObject(0)
.getJSONArray("emotions");
jem2.put(jemotions);
return jsonobjexist;
}
private JSONArray performASR2(String wavefilename) throws IOException,InterruptedException{
String r = String.valueOf(Math.random()).replace(".", "_");
Process p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/asr_upload.sh "+wavefilename);
p.waitFor();
String line="";
String fullLine1="";
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine1=fullLine1+line;
JSONObject j = new JSONObject(fullLine1);
if(!(j.has("result") && j.getJSONObject("result").has("name")))
return null;//"ASR unsucessfull";
//running asr
p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/asr_run.sh "+wavefilename);
p.waitFor();
String fullLine3="";
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine3=fullLine3+line;
j = new JSONObject(fullLine3);
String id = j.getJSONObject("result").getJSONObject("info").getString("id");
while(true){
String fullLine4="";
Thread.sleep(2000);
p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/checkpending.sh "+id);
p.waitFor();
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine4=fullLine4+line;
j = new JSONObject(fullLine4);
if(!j.getJSONObject("result").has("info") || j.getJSONObject("result").getJSONObject("info").getString("state").compareTo("finished")==0)
break;
}
p = Runtime.getRuntime().exec(paths.SMILExtractDir+"asr/asr_run.sh "+wavefilename);
p.waitFor();
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String fullLine5="";
while((line=in.readLine())!=null)
fullLine5=fullLine5+line;
j = new JSONObject(fullLine5);
JSONArray jo = j.getJSONObject("result").getJSONObject("one_best_result").getJSONArray("segmentation");
return jo;
}
private String performASR(String wavefilename) throws IOException,InterruptedException{
String r = String.valueOf(Math.random());
String fname = paths.FileDirectory + "asrout"+r+".tmp";
Process p = Runtime.getRuntime().exec(
"sh " + paths.SMILExtractDir +"asr_prep.sh "+ wavefilename);
p.waitFor();
FileReader f = new FileReader(wavefilename+".asrupload.txt");
BufferedReader br = new BufferedReader(f);
String aline;
boolean passed = false;
while((aline = br.readLine())!=null){
if(aline.contains("info format")){
passed = true;break;
}
}
br.close();
if (passed == false){
return "Posting file to ASR server failed";
}
f = new FileReader(wavefilename+".asrloc.txt");
String locationOnServer="";
br = new BufferedReader(f);
while((aline = br.readLine())!=null){
if(aline.contains("Location")){
locationOnServer = aline.substring(10);
break;
}
}
br.close();
boolean asr = false;
do{
Thread.sleep(2000);
p = Runtime.getRuntime().exec(
"sh " + paths.SMILExtractDir +"asr_get_res.sh "+ locationOnServer +" "+fname+".trans.txt");
p.waitFor();
f = new FileReader(fname+".trans.txt");
br = new BufferedReader(f);
while((aline = br.readLine())!=null){
if(aline.contains("result name=\"lvcsr\"")){
asr = true;br.close();
break;
}
}
}while(asr==false);
p = Runtime.getRuntime().exec(
"bash " + paths.SMILExtractDir + "asr_processor.sh " + fname + ".trans.txt " + wavefilename +" "+fname+".json");
p.waitFor();
return fname;
}
public static String readFile(String filename) throws IOException {
FileReader f = new FileReader(filename);
BufferedReader br = new BufferedReader(f);
String s = "";
String aline;
while((aline = br.readLine())!=null){
s = s + aline;
}
br.close();
return s;
}
static public JSONObject loadJsonObject(String jsonfilename) {
String line = "";
String jsonTxt = "";
BufferedReader is = null;
try {
is = new BufferedReader(new InputStreamReader(new FileInputStream(
jsonfilename)));
while ((line = is.readLine()) != null) {
jsonTxt += line;
}
is.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
JSONObject jsonobjexist = new JSONObject(jsonTxt);
return jsonobjexist;
}
private JSONObject write2JSON(String url, Integer index, String time,
String duration, JSONArray jaresult) {
JSONObject json = new JSONObject();
JSONArray jarray = new JSONArray();
JSONObject emovoc = new JSONObject();
emovoc.put("emovoc",
"http://www.gsi.dit.upm.es/ontologies/onyx/vocabularies/emotionml/ns");
jarray.put(emovoc);
json.put("@context", jarray);
JSONArray janalysisarray = new JSONArray();
JSONObject janalysis = new JSONObject();
janalysis.put("@id", "me:SpeechAnalysis");
janalysis.put("@type", "onyx:EmotionAnalysis");
janalysis.put("onyx:usesEmotionModel", "emovoc:pad-dimensions");
janalysisarray.put(janalysis);
json.put("analysis", janalysisarray);
JSONArray jemotionsarray = new JSONArray();
JSONObject jemotion = new JSONObject();
jemotion.put("@id", "Entry" + index.toString() + "#time=" + time + ","
+ duration);
jemotion.put("prov:wasGeneratedBy", "me:SpeechAnalysis");
jemotion.put("onyx:hasEmotion", jaresult);
jemotionsarray.put(jemotion);
JSONObject jentry = new JSONObject();
jentry.put("emotions", jemotionsarray);
JSONArray jentriesarray = new JSONArray();
jentriesarray.put(jentry);
json.put("entries", jentriesarray);
return json;
}
private File cutAudio(File file, String startTime, String duration,
double d) {
File F = new File(file + "_p" + ((Double)d).toString() + ".wav");
try {
if (F.exists())
F.delete();
String durationStr = "";
if(startTime.startsWith(".")){
startTime = startTime+" ";
startTime = "0"+String.copyValueOf(startTime.toCharArray(), 0, startTime.length()-1);
}
if (startTime.compareTo("-1") == 0)
startTime = "0";
if (duration.compareTo("-1") != 0)
durationStr = " -t " + duration;
if(durationStr.startsWith(".")){
durationStr = durationStr+" ";
durationStr = "0"+String.copyValueOf(durationStr.toCharArray(), 0, durationStr.length()-1);
}
Process p = Runtime.getRuntime().exec(
"avconv" + " -i " + file + " -acodec copy " + " -ac 1 -ss "
+ startTime + // start
durationStr + // duration
" " + F.toString());
p.waitFor();
p = Runtime.getRuntime().exec(
"qwavheaderdump -q -F " + F.toString());// Fixing header
p.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
return F;
}
// convert av to .wav
private File convertToWave(File file) {
File F = new File(file.toString() + ".wav");
try {
if(F.exists())
F.delete();
//if (!F.exists())
Process p = Runtime.getRuntime().exec(
"avconv -loglevel quiet -i " + file + " -ac 1 -vn -f wav "
+ F.toString());
p.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
return F;
}
// download the resource
private File wget(String url) {
String[] urls = url.split("/");
String output = paths.FileDirectory + urls[urls.length - 1];
File F = new File(output);
try {
if (!F.exists()) {
Process p = Runtime.getRuntime().exec(
"wget -q -O " + output + " " + url);
p.waitFor();
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
F = null;
logger_instance.write(
1,
"wget exception: wget -q -O " + output + " " + url + "\n"
+ e.getMessage());
logger_instance.close();
}
return F;
}
private double getAudioDuration(String filename){
File file = new File(filename);
AudioInputStream audioInputStream;
float durationInSeconds = 0;
try {
audioInputStream = AudioSystem.getAudioInputStream(file);
AudioFormat format = audioInputStream.getFormat();
long audioFileLength = file.length();
int frameSize = format.getFrameSize();
float frameRate = format.getFrameRate();
durationInSeconds = (audioFileLength / (frameSize * frameRate));
} catch (UnsupportedAudioFileException | IOException e) {
e.printStackTrace();
}
return durationInSeconds;
}
private String genderateHelp(){
return "You have to set these parameters:\n" +
"getdims: desired dimentions separated by comma (arousal,valence,age,gender,big5O,big5C,big5E,big5A,big5N,sentiment)\n"+
" note that, to have sentiment, you should only have 'asr' (automatic speech recognition) in the 'timing' parameter.'\n"+
"url:the url of the video/audio or the name of the uploaded file\n"+
"timing: start and end of the segments (in seconds). start1,end1;start2,end2, OR asr\n"+
" when you choose 'asr', the audio file is segmented for each spoken sentence (useful for sentiment recognition) \n"+
"Example:\n"+
"http://mixedemotions.fim.uni-passau.de:8080/er/aer/getdims?dims=arousal,valence,gender,age,big5o,big5c,big5e,big5a,big5n&url=http://tv-download.dw.com/dwtv_video/flv/wikoe/wikoe20151114_wiruebli_sd_avc.mp4&timing=9,15;147,152"+
"\n\n"+
"To upload an audio/video file use curl:\n"+
"Windows: curl -v -H \"Content-Type:multipart/form-data\" --user meuser -i -X POST -F \"file=@D:\\path\\to\\sample.wav\" http://mixedemotions.fim.uni-passau.de:8080/er/aer/upload\n"+
"Linux: curl -v -H \"Content-Type:multipart/form-data\" --user meuser -i -X POST -F 'file=@./sample.wav' http://mixedemotions.fim.uni-passau.de:8080/er/aer/upload\n"+
"\n"+
"GUI interface: http://mixedemotions.fim.uni-passau.de:8080/er/FileUpload.html"
;
}
// save uploaded file to new location
private void writeToFile(InputStream uploadedInputStream,
String uploadedFileLocation) {
try {
OutputStream out = new FileOutputStream(new File(
uploadedFileLocation));
int read = 0;
byte[] bytes = new byte[1024];
out = new FileOutputStream(new File(uploadedFileLocation));
while ((read = uploadedInputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,12 @@
package com.opensmile.maven;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
@ApplicationPath("/")
public class MyApplication extends ResourceConfig {
public MyApplication(){
super(EmoRecService.class,MultiPartFeature.class);
}
}
@@ -0,0 +1,13 @@
package com.opensmile.maven;
//package com.opensmile.first;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
@ApplicationPath("/")
public class MyApplication extends ResourceConfig {
public MyApplication(){
super(EmoRecService.class,MultiPartFeature.class);
}
}
@@ -0,0 +1,58 @@
package com.opensmile.maven;
/*package com.opensmile.first;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
//import org.glassfish.jersey multipart.FormDataContentDisposition;
//import com.sun.jersey.multipart.FormDataParam;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
@Path("/fileupload")
public class UploadFileService {
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {
String uploadedFileLocation = "/media/sag/DATA/eclipse_workspace/UploadedFiles/" + fileDetail.getFileName();
// save it
saveToFile(uploadedInputStream, uploadedFileLocation);
String output = "File uploaded via Jersey based RESTFul Webservice to: " + uploadedFileLocation;
return Response.status(200).entity(output).build();
}
// save uploaded file to new location
private void saveToFile(InputStream uploadedInputStream,
String uploadedFileLocation) {
try {
OutputStream out = null;
int read = 0;
byte[] bytes = new byte[1024];
out = new FileOutputStream(new File(uploadedFileLocation));
while ((read = uploadedInputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}*/
@@ -0,0 +1,76 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import org.json.JSONException;
import org.json.JSONObject;
public class bashClassifier extends Classifier {
String run_command = "";
@Override
public boolean configure(JSONObject json) {
run_command = json.getString("run_command");
onyxentity = json.getString("onyxentity");
intype = json.getString("intype");
return true;
}
@Override
public JSONObject classify(String audioFile) {
String line="";
String fullLine="";
int idx = run_command.lastIndexOf("/");
String full_path = paths.SMILExtractDir+run_command.substring(0,idx);
String str = "bash "+paths.SMILExtractDir+run_command+" "+audioFile;
try {
logger_instance.write(1,"full_path="+full_path);
logger_instance.write(1,"bash command: " + str);
for(int trial=0;trial<3;trial++){
fullLine="";
Process p = Runtime.getRuntime().exec(str,null,new File(full_path));
p.waitFor();
logger_instance.write(1,"bash command performed");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
if(fullLine.length()>0)
break;
}
logger_instance.write(1,"bash output:"+ fullLine);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
JSONObject jo = null;
try{
jo = new JSONObject(fullLine.substring(fullLine.indexOf("{")));
}catch (JSONException e){
System.out.println(fullLine);
e.printStackTrace();
}
catch(StringIndexOutOfBoundsException e){
System.out.println(fullLine);
e.printStackTrace();
}
JSONObject jop = new JSONObject();
switch((String)jo.get("TYPE")){
case "regression":
double out = jo.getDouble("VALUE");
double conf = (double)(((JSONObject)jo.getJSONArray("PROB").get(0)).getDouble("CONFIDENCE"));
jop.put(onyxentity, out);
jop.put("confidence", conf);
break;
case "classification":
jop.put(onyxentity, jo.getJSONArray("PROB"));
break;
}
return jop;
}
}
@@ -0,0 +1,84 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import org.json.JSONException;
import org.json.JSONObject;
public class bashClassifier extends Classifier {
String run_command = "";
@Override
public boolean configure(JSONObject json) {
run_command = json.getString("run_command");
onyxentity = json.getString("onyxentity");
intype = json.getString("intype");
return true;
}
@Override
public JSONObject classify(String audioFile) {
String line="";
String fullLine="";
/*if(model.compareTo("Arousal")==0)
prepareConfigFile("svmarousal");
if(model.compareTo("Valence")==0)
prepareConfigFile("svmvalence");
*/
int idx = run_command.lastIndexOf("/");
String full_path = paths.SMILExtractDir+run_command.substring(0,idx);
String str = "bash "+paths.SMILExtractDir+run_command+" "+audioFile;
try {
logger_instance.write(1,"full_path="+full_path);
logger_instance.write(1,"bash command: " + str);
for(int trial=0;trial<3;trial++){
fullLine="";
Process p = Runtime.getRuntime().exec(str,null,new File(full_path));
p.waitFor();
logger_instance.write(1,"bash command performed");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
if(fullLine.length()>0)
break;
}
logger_instance.write(1,"bash output:"+ fullLine);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
JSONObject jo = null;
try{
jo = new JSONObject(fullLine.substring(fullLine.indexOf("{")));
}catch (JSONException e){
System.out.println(fullLine);
e.printStackTrace();
}
catch(StringIndexOutOfBoundsException e){
System.out.println(fullLine);
e.printStackTrace();
}
//int idx1 = fullLine.indexOf("~~>");
//int idx2 = fullLine.indexOf("<~~");
//out = fullLine.substring(idx1+3, idx2-1);
JSONObject jop = new JSONObject();
switch((String)jo.get("TYPE")){
case "regression":
double out = jo.getDouble("VALUE");
double conf = (double)(((JSONObject)jo.getJSONArray("PROB").get(0)).getDouble("CONFIDENCE"));
jop.put(onyxentity, out);
jop.put("confidence", conf);
break;
case "classification":
jop.put(onyxentity, jo.getJSONArray("PROB"));
break;
}
return jop;
}
}
+37
Ver Arquivo
@@ -0,0 +1,37 @@
package com.opensmile.maven;
/**
* @author Crunchify.com
*/
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@Path("/ctofservice")
public class ctofservice {
@GET
@Produces("application/xml")
public String convertCtoF() {
Double fahrenheit;
Double celsius = 36.8;
fahrenheit = ((celsius * 9) / 5) + 32;
String result = "@Produces(\"application/xml\") Output: \n\nC to F Converter Output: \n\n" + fahrenheit;
return "<ctofservice>" + "<celsius>" + celsius + "</celsius>" + "<ctofoutput>" + result + "</ctofoutput>" + "</ctofservice>";
}
@Path("{c}")
@GET
@Produces("application/xml")
public String convertCtoFfromInput(@PathParam("c") Double c) {
Double fahrenheit;
Double celsius = c;
fahrenheit = ((celsius * 9) / 5) + 32;
String result = "@Produces(\"application/xml\") Output: \n\nC to F Converter Output: \n\n" + fahrenheit;
return "<ctofservice>" + "<celsius>" + celsius + "</celsius>" + "<ctofoutput>" + result + "</ctofoutput>" + "</ctofservice>";
}
}
+61
Ver Arquivo
@@ -0,0 +1,61 @@
package com.opensmile.maven;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class logger {
//private static volatile logger logger_instance;
static PrintWriter F;
int debug_priority = 1;
static String filename;
logger() {
try {
F = new PrintWriter(paths.logFolder + filename + ".txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
logger(String filename){
try {
logger.filename=filename;
F = new PrintWriter(paths.logFolder + filename + ".txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
void write(int priority, String s) {
if (priority > debug_priority)
return;
synchronized (logger.class) {
if (F == null)
try {
F = new PrintWriter(paths.logFolder + filename + ".txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
// Get the date today using Calendar object.
Date today = Calendar.getInstance().getTime();
// Using DateFormat format method we can create a string
// representation of a date with the defined format.
String reportDate = df.format(today);
// Print what date is today!
F.append(reportDate + " ---- " + s + "\n");
F.flush();
}
}
void close() {
F.close();
}
public String file_name() {
return paths.logFolder + filename + ".txt";
}
}
+79
Ver Arquivo
@@ -0,0 +1,79 @@
package com.opensmile.maven;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class logger {
//private static volatile logger logger_instance;
static PrintWriter F;
int debug_priority = 1;
static String filename;
logger() {
try {
F = new PrintWriter(paths.logFolder + filename + ".txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
logger(String filename){
try {
logger.filename=filename;
F = new PrintWriter(paths.logFolder + filename + ".txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
/*static logger getinstance(String filename){
logger
return logger_instance;
}
/* static logger getinstance() {
if (logger_instance == null) {
synchronized (logger.class) {
if (logger_instance == null)
logger_instance = new logger();
}
}
return logger_instance;
}*/
void write(int priority, String s) {
if (priority > debug_priority)
return;
synchronized (logger.class) {
if (F == null)
try {
F = new PrintWriter(paths.logFolder + filename + ".txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
// Get the date today using Calendar object.
Date today = Calendar.getInstance().getTime();
// Using DateFormat format method we can create a string
// representation of a date with the defined format.
String reportDate = df.format(today);
// Print what date is today!
F.append(reportDate + " ---- " + s + "\n");
F.flush();
}
// F.println(s);
}
void close() {
F.close();
}
public String file_name() {
return paths.logFolder + filename + ".txt";
}
}
@@ -0,0 +1,58 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import org.json.JSONObject;
public class openSMILEclassifier extends Classifier {
@Override
public boolean configure(JSONObject jo) {
configFile = jo.getString("config");
onyxentity = jo.getString("onyxentity");
intype = jo.getString("intype");
return true;
}
@Override
public JSONObject classify(String audioFile) {
String line="";
String fullLine="";
try {
String str = paths.SMILExtractDir+"SMILExtract "+
" -C "+paths.SMILExtractDir+configFile+
" -I "+audioFile+ " -l 1";
Process p = Runtime.getRuntime().exec(str,null,new File(paths.SMILExtractDir));
logger_instance.write(1,"opensmile command: " + str);
p.waitFor();
logger_instance.write(1,"opensmile command performed");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
logger_instance.write(1,"opensmile output:"+ fullLine);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
JSONObject jo = new JSONObject(fullLine);
JSONObject jop = new JSONObject();
switch((String)jo.get("TYPE")){
case "regression":
double out = jo.getDouble("VALUE");
double conf = (double)((JSONObject)jo.getJSONArray("PROB").get(0)).get("CONFIDENCE");
jop.put(onyxentity, out);
jop.put("confidence", conf);
break;
case "classification":
jop.put(onyxentity, jo.getJSONArray("PROB"));
break;
}
return jop;
}
}
@@ -0,0 +1,84 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import org.json.JSONObject;
public class openSMILEclassifier extends Classifier {
@Override
public boolean configure(JSONObject jo) {
configFile = jo.getString("config");
onyxentity = jo.getString("onyxentity");
intype = jo.getString("intype");
return true;
/*Process p;
try {
p = Runtime.getRuntime().exec("cp "+paths.SMILExtractDir+paths.SMILEconfig+ " "+
paths.SMILExtractDir+paths.SMILEconfigAugmented);
p.waitFor();
String[] cmd={"sh","-c","echo model="+paths.SMILExtractDir+SVMModelName+".model"+
" >> "+paths.SMILExtractDir+paths.SMILEconfigAugmented};
p = Runtime.getRuntime().exec(cmd);
p.waitFor();
String[] cmd2={"sh","-c","echo scale="+paths.SMILExtractDir+SVMModelName+".scale"+
" >> "+paths.SMILExtractDir+paths.SMILEconfigAugmented};
p = Runtime.getRuntime().exec(cmd2);
p.waitFor();
} catch (IOException | InterruptedException e) {
e.printStackTrace();
return false;
}*/
}
@Override
public JSONObject classify(String audioFile) {
//String out = "";
String line="";
String fullLine="";
/*if(model.compareTo("Arousal")==0)
prepareConfigFile("svmarousal");
if(model.compareTo("Valence")==0)
prepareConfigFile("svmvalence");
*/
try {
String str = paths.SMILExtractDir+"SMILExtract "+
" -C "+paths.SMILExtractDir+configFile+
" -I "+audioFile+ " -l 1";
Process p = Runtime.getRuntime().exec(str,null,new File(paths.SMILExtractDir));
logger_instance.write(1,"opensmile command: " + str);
p.waitFor();
logger_instance.write(1,"opensmile command performed");
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while((line=in.readLine())!=null)
fullLine=fullLine+line;
logger_instance.write(1,"opensmile output:"+ fullLine);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
JSONObject jo = new JSONObject(fullLine);
//int idx1 = fullLine.indexOf("~~>");
//int idx2 = fullLine.indexOf("<~~");
//out = fullLine.substring(idx1+3, idx2-1);
JSONObject jop = new JSONObject();
switch((String)jo.get("TYPE")){
case "regression":
double out = jo.getDouble("VALUE");
double conf = (double)((JSONObject)jo.getJSONArray("PROB").get(0)).get("CONFIDENCE");
jop.put(onyxentity, out);
jop.put("confidence", conf);
break;
case "classification":
jop.put(onyxentity, jo.getJSONArray("PROB"));
break;
}
return jop;
}
}
+51
Ver Arquivo
@@ -0,0 +1,51 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class paths {
static String FileDirectory = getVar("REST_FILES");
static String SMILExtractDir = getVar("REST_OPENSMILE");
static String logFile = getVar("REST_OPENSMILE") + "/log.txt";
static String logFolder = getVar("REST_OPENSMILE") + "/logs/";
static String SMILEconfig = "IS09_emotion_Mine_AR_res_4corpus_0_FE.conf";
static String SMILEconfigAugmented = "IS09_emotion_Mine_AR_res_4corpus_0_FE_Augmented.conf";
static String getVar(String varname) {
BufferedReader bufferedReader = null;
File f = null;
var_file = "/path/to/rest_vars";
try {
f = new File(var_file);
System.out.println(f.getAbsolutePath());
if (!f.exists()) {
System.out.println(f.getAbsolutePath() + " does not exist!");
FileNotFoundException e = new FileNotFoundException();
throw e;
}
bufferedReader = new BufferedReader(new FileReader(var_file));
String line;
String[] ls;
while ((line = bufferedReader.readLine()) != null) {
if (line.length() < 2) {
bufferedReader.close();
return "";
}
ls = line.split("=");
if (ls[0].compareTo(varname) == 0) {
bufferedReader.close();
return ls[1];
}
}
bufferedReader.close();
} catch (IOException e) {
e.printStackTrace();
return f.getAbsolutePath() + " " + e.getMessage();
}
return "";
}
}
+67
Ver Arquivo
@@ -0,0 +1,67 @@
package com.opensmile.maven;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class paths {
static String FileDirectory = getVar("REST_FILES");
static String SMILExtractDir = getVar("REST_OPENSMILE");
static String logFile = getVar("REST_OPENSMILE") + "/log.txt";
static String logFolder = getVar("REST_OPENSMILE") + "/logs/";
static String SMILEconfig = "IS09_emotion_Mine_AR_res_4corpus_0_FE.conf";
static String SMILEconfigAugmented = "IS09_emotion_Mine_AR_res_4corpus_0_FE_Augmented.conf";
static String var_file = "/var/rest_vars";
static String getVar(String varname) {
// return "done";
BufferedReader bufferedReader = null;
File f = null;
var_file = "/var/rest_vars";
try {
// return var_file;
f = new File(var_file);
// return "done"+f.getAbsolutePath();
System.out.println(f.getAbsolutePath());
if (!f.exists()) {
System.out.println(f.getAbsolutePath() + " does not exist!");
FileNotFoundException e = new FileNotFoundException();
throw e;
}
bufferedReader = new BufferedReader(new FileReader(var_file));
String line;
String[] ls;
while ((line = bufferedReader.readLine()) != null) {
if (line.length() < 2) {
bufferedReader.close();
return "";
}
ls = line.split("=");
if (ls[0].compareTo(varname) == 0) {
bufferedReader.close();
return ls[1];
}
}
bufferedReader.close();
} catch (IOException e) {
// System.out.println();
e.printStackTrace();
return f.getAbsolutePath() + " " + e.getMessage();
}
return "";
}
/*
* static String getBashVar(String varname){ Process p; String line; String
* fullLine=""; String ls[]; try { String[]
* cmd={"sh","-c","echo &"+varname};// | grep "+varname+" |
* tee"};//echo $"+varname}; p = Runtime.getRuntime().exec(cmd);//
* p.waitFor(); BufferedReader in = new BufferedReader(new
* InputStreamReader(p.getInputStream()));
* while((line=in.readLine())!=null){ ls = line.split("=");
* if(ls[0].compareTo(varname)==0) return ls[1]; } } catch (IOException |
* InterruptedException e) { e.printStackTrace(); } return fullLine; }
*/
}
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.
Arquivo binário não exibido.

Alguns arquivos não foram exibidos porque demasiados arquivos foram alterados neste diff Mostrar Mais