Commit feababba authored by mistermad's avatar mistermad

- Added deployment from the APK and basic files to test the functionality of LIG-Aikuma

- Verification of the validity of text files of the opening in eliciting mode
- Better working video and image files in eliciting mode
- Minor bug fix when importing a profile in respeking mode (not importing the "note" field)
parent 5f0d9e6e
Yes. |Of course. ## Oui. |Naturellement.
Thank you. ## Merci.
Excuse me. ## Excusez- moi.
Takeout, please. ## À emporter, svp.
Can I have something to eat? ## Est-ce que je peux avoir quelque chose à manger ?
What kind of drinks do you have? ## Quel genre de boissons as-tu ?
Excuse me. ## Excusez- moi.
Takeout, please. ## À emporter, svp.
Can I have something to eat? ## Est-ce que je peux avoir quelque chose à manger ?
What kind of drinks do you have? ## Quel genre de boissons as-tu ?
Are you eating here or taking out? ## Est-ce que tu manges ici ou sors ?
Eating here. ## Manger ici.
Taking out. ## Sortie.
I'll have a cheeseburger, a small French fry and a medium coke, please. ## J'aurai un cheeseburger, un petit French.fry et un coke moyen, svp.
One sandwich and one orange juice, please. ## Un sandwich et un jus d'orange, svp.
I'll have this and this. ## J'aurai ceci et ceci.
Do you have ketchup? ## Prends-tu le ketchup ?
I ordered a French fry. ## J'ai commandé un French.fry.
Is this the large size? ## Est-ce que c'est la grande taille ?
I'd like to have another cup. ## Je voudrais avoir une autre tasse.
Can you tell me where the nearest cafeteria is? ## Peus-tu me dire où le cafétéria le plus proche est ?
How would you like your eggs? ## Comment tu aiment vos oeufs ?
Scrambled eggs with bacon, please. ## Oeufs brouillés avec le lard, svp.
Soft-boiled eggs, please. ## oeufs Doux-bouillis, svp.
Some more coffee? ## Encore plus de café ?
Yes, please. ## Oui, svp.
No, thank you. ## Non, merci.
Next please. ## Veuillez après.
Two hot dogs and one coke, please. ## Deux hot-dogs et un coke, svp.
With mustard and ketchup? ## Avec de la moutarde et le ketchup ?
Just ketchup, please. ## Ketchup juste, svp.
Both, please. ## Tous les deux, svp.
Easy on the mustard, please. ## Facile sur la moutarde, svp.
With mustard, ketchup, or relish? ## Avec de la moutarde, le ketchup, ou le goût ?
No, thanks, I like it plain. ## Non, merci, je l'aime plat.
With mustard, onions, hold the ketchup, please. ## Avec de la moutarde, les oignons, tiennent le ketchup, svp.
What do you want on it? ## Que veus-tu là-dessus ?
Do you want large or small? ## Veus-tu grand ou petit ?
A large one, please. ## Grand , svp.
A hamburger and a milk shake, please. ## Un hamburger et un lait de poule , svp.
Do you want tomato and cheese on your hamburger? ## Veus-tu la tomate et le fromage sur votre hamburger ?
Just tomato, please. ## Tomate juste, svp.
Eat-in or take-out? ## Manger-dans ou à emporter ?
Take-out, please. ## À emporter, svp.
I'll eat here. ## Je mangerai ici.
Here or to go? ## Ici ou pour aller ?
To go. ## Pour aller.
Anything else? ## Toute autre chose ?
No, thanks. ## Non, merci.
Do you want to warm it up? ## Veus-tu le chauffer ?
Yes, please. ## Oui, svp.
How do you use this vending machine? ## Comment utilises-tu ce distributeur automatique automatique ?
I put money in but nothing came out. ## J'ai mis l'argent dans mais rien n'a sorti.
Good morning. |How are you, sir? ## Bonjour. |Comment vais tu, monsieur ?
Fine, thank you. ## Très bien, merci.
Here's a menu, sir. ## Voici une carte, monsieur.
Thank you. ## Merci.
I will have American breakfast. ## Je prendrai le petit déjeuner américain.
What kind of juice would you like to have? ## Quel genre de jus aimes-tu avoir ?
Do you have pineapple juice? ## Prends-tu le jus d'ananas ?
Sorry, we don't have, today. ## Désolés, nous n'avons pas, aujourd'hui.
All right. |Then give me grapefruit juice, please. ## Bien. |Donnez- alors moi le jus de pamplemousse, svp.
Yes, and? ## Oui, et ?
Toast, cheese omelet with buttered toast, two fried eggs, over easy with ham and coffee, please. ## Le pain grillé, omelette de fromage avec du pain grillé beurré, deux a fait frire des oeufs, excédent facile avec du jambon et café, svp.
Shall I bring coffee now? ## Est-ce que je dois apporter le café maintenant ?
Yes, please. ## Oui, svp.
Here is a menu, sir. ## Voici une carte, monsieur.
Thank you. |I'm in a hurry. |What can you serve quickly? ## Merci. |Je suis pressé. |Ce qui peut tu servir rapidement ?
Let me see. |Yes, today's special lunch would be served quickly. ## Laissez- moi voir. |Oui, le déjeuner spécial d'aujourd'hui serait servi rapidement.
What is the today's special? ## Quel est le spécial d'aujourd'hui ?
A bowl of cream soup, fried prawn with lemon, butter, parsley potatoes, green salad, rolls, and coffee or tea. ## Un bol de potage crème, de crevette rose frite avec le citron, de beurre, de pommes de terre persillées , de salade verte, de roulements, et de café ou de thé.
Okay, I'll take it. ## Ok, je le prendrai.
Yes, sir. ## Oui, monsieur.
No, thank you. |And check, please. ## Non, merci. |Et contrôle, svp.
Certainly, sir. ## Certainement, monsieur.
Where should I pay? ## Où devrais-je payer ?
Please pay at the cashier over there. ## Svp salaire au caissier là-bas.
I see. |Thank you very much. ## Je vois. |Merci beaucoup.
One coffee and one hamburger, please. ## Un café et un hamburger, svp.
Yes, please. |What kinds of ice cream do you have? ## Oui, svp. |Quels genres de crême glacée tu ont ?
Vanilla, chocolate and strawberry. ## Vanille, chocolat et fraise.
May I help you? ## Est-ce que je peux t'aider ?
Give me coffee and apple pie, please. ## Donnez- moi le pâté en croûte de café et de pomme, svp.
Black or white? ## Noir ou blanc ?
Black, please. ## Noir, svp.
Mustard? ## Moutarde ?
No, ketchup, please. ## Non, ketchup, svp.
How do you like it? ## Comment tu l'aiment ?
Wonderful. ## Merveilleux.
One hamburger and one orange shake, please. ## Un hamburger et une secousse orange, svp.
Right. |Here you are. ## Droite. |Ici tu es.
Oh, this is America. ## Ah, ceci est l'Amérique.
You like America? |Very good. ## Tu aimes l'Amérique ? |Très bon.
What's New Orleans nectar? ## Quel est nectar de la Nouvelle-Orléans ?
Oh, it's an ice cream soda. ## Ah, c'est une soude de crême glacée.
Please give me that one. |What do you call that? ## Veuillez me donner celui-là. |Ce qui tu appellent cela ?
That's a banana split. ## C'est un banana split.
Do you have banana ice cream? ## As-tu la crême glacée de banane ?
Sure. |You want one? ## Sûr. |Tu veus un ?
Yes, please. |How much is it? ## Oui, svp. |Combien coûte lui ?
package org.getalp.ligaikuma.lig_aikuma;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Language;
import org.getalp.ligaikuma.lig_aikuma.model.RecordingLig;
import org.getalp.ligaikuma.lig_aikuma.ui.CheckMode;
import org.getalp.ligaikuma.lig_aikuma.ui.CheckTranscription;
import org.getalp.ligaikuma.lig_aikuma.ui.CheckWordVariant;
import org.getalp.ligaikuma.lig_aikuma.ui.ElicitationMode;
import org.getalp.ligaikuma.lig_aikuma.ui.RecordElicitation;
import org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataLig;
import org.getalp.ligaikuma.lig_aikuma.ui.RespeakingSelection;
import org.getalp.ligaikuma.lig_aikuma.ui.ShareFileActivity;
import org.getalp.ligaikuma.lig_aikuma.ui.ThumbRespeakActivityLig;
import org.getalp.ligaikuma.lig_aikuma.ui.sensors.LocationDetector;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
......@@ -37,16 +12,39 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.semantive.waveformandroid.waveform.MediaPlayerFactory;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.BuildConfig;
import org.getalp.ligaikuma.lig_aikuma.lig_aikuma.R;
import org.getalp.ligaikuma.lig_aikuma.model.Language;
import org.getalp.ligaikuma.lig_aikuma.model.RecordingLig;
import org.getalp.ligaikuma.lig_aikuma.ui.CheckMode;
import org.getalp.ligaikuma.lig_aikuma.ui.CheckTranscription;
import org.getalp.ligaikuma.lig_aikuma.ui.CheckWordVariant;
import org.getalp.ligaikuma.lig_aikuma.ui.ElicitationMode;
import org.getalp.ligaikuma.lig_aikuma.ui.RecordElicitation;
import org.getalp.ligaikuma.lig_aikuma.ui.RecordingMetadataLig;
import org.getalp.ligaikuma.lig_aikuma.ui.RespeakingSelection;
import org.getalp.ligaikuma.lig_aikuma.ui.ShareFileActivity;
import org.getalp.ligaikuma.lig_aikuma.ui.ThumbRespeakActivityLig;
import org.getalp.ligaikuma.lig_aikuma.ui.sensors.LocationDetector;
import org.getalp.ligaikuma.lig_aikuma.util.AikumaSettings;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
public class ModeSelection extends Activity implements OnClickListener{
private static final String TAG = "ModeSelection";
......@@ -69,17 +67,12 @@ public class ModeSelection extends Activity implements OnClickListener{
if(BuildConfig.DEBUG)Log.i(TAG, AikumaSettings.getCurrentUserId());
}
// DEBUG
if(BuildConfig.DEBUG) {
Map<String, ?> mapPrefs = settings.getAll();
for(String key : mapPrefs.keySet())
Log.i(TAG, "DEBUG - Shared Preferences - " + key + " -> " + mapPrefs.get(key));
}
// hides the action bar instead of removing it
// getActionBar().hide();
Aikuma.loadLanguages(this.getApplicationContext());
findViewById(R.id.button_mode_record).setOnClickListener(this);
......@@ -94,6 +87,13 @@ public class ModeSelection extends Activity implements OnClickListener{
// check the existing session and show popup to propose retrieving it
prefsUserSession = getSharedPreferences("userSession", MODE_PRIVATE);
ed = prefsUserSession.edit();
File f = new File(FileIO.getAppRootPath()+"/example");
if(!f.exists())
{
f.mkdir();
FileIO.copyFilesFromAssets(this);
}
}
@Override
......
......@@ -66,23 +66,15 @@ public class TranscriptPlayer extends MarkedPlayer
setNotificationMarkerPosition(segment);
}
// Update the UI such that the transcript reflects the current sample.
// Never use
/*private void updateTranscriptUi(long sample) {
Segment segment = transcript.getSegmentOfSample(sample);
updateTranscriptUi(segment);
}*/
// Update the UI such that the transcript reflects the current segment.
private void updateTranscriptUi(Segment segment) {
TextView transcriptView = (TextView) activity.findViewById(R.id.transcriptView);
TextView transcriptView2 = (TextView) activity.findViewById(R.id.transcriptView2);
if (segment != null) {
transcriptView.setText(transcript.getTranscriptPair(segment).transcript);
transcriptView2.setText(transcript.getTranscriptPair(segment).translation);
((TextView) activity.findViewById(R.id.transcriptView)).setText(transcript.getTranscriptPair(segment).transcript);
((TextView) activity.findViewById(R.id.transcriptView2)).setText(transcript.getTranscriptPair(segment).translation);
}
else
transcriptView.setText("");
((TextView) activity.findViewById(R.id.transcriptView)).setText("");
}
@Override
......@@ -96,15 +88,4 @@ public class TranscriptPlayer extends MarkedPlayer
//private static Segment segment;
private TempTranscript transcript;
private Activity activity;
/*
/**
* Listener to adjust the transcript view when a transcript marker gets reached.
private class TranscriptMarkerReachedListener
extends MarkedPlayer.OnMarkerReachedListener {
public void onMarkerReached(MarkedPlayer p) {
transcriptView.setText("different");
}
}
*/
}
......@@ -18,7 +18,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.UUID;
import static org.getalp.ligaikuma.lig_aikuma.model.RecordingLig.MAP_EXT;
......@@ -175,22 +174,19 @@ public class Mapper {
*/
public void remap(int[] index)
{
Log.d(TAG, "Start remap: "+Arrays.toString(index));
Log.d(TAG, "Destination: "+new File(FileIO.getNoSyncPath(),"tmp_no_speak"+MAP_EXT).toString());
if(index.length==0) return;
String bufferWrite="";
Arrays.sort(index);
try {
// Read original map file and remap it on buffer
String[] v = FileIO.read(mappingFile).split("\n");
for(int i=0,j=0;i<v.length;i++)
if(i==index[j])
{
bufferWrite+=v[i]+"\n";
for(int i=0,j=0;i<v.length&&j<index.length;i++) {
if (i == index[j]) {
bufferWrite += v[i] + "\n";
j++;
}
// Write buffer on new map file
Log.d(TAG, "Buffer:\n"+bufferWrite);
FileIO.write(new File(FileIO.getNoSyncPath(),"tmp_no_speak"+MAP_EXT), bufferWrite);
}
FileIO.write(new File(FileIO.getNoSyncPath(),"tmp_no_speech"+MAP_EXT), bufferWrite);
} catch (IOException ignored) {}
}
}
......@@ -218,6 +218,10 @@ public class ThumbRespeaker {
public int[] getRemap() {return _remapIndex;}
public void setDestRecFullPath(String p){_dest_rec_full_path=p;}
public String getDestRecFullPath(){return _dest_rec_full_path;}
/** Player to play the original with. */
private SimplePlayer player;
......@@ -239,6 +243,8 @@ public class ThumbRespeaker {
/** The amount to rewind the original in msec
* after each respeaking-segment. */
private int rewindAmount;
private String _dest_rec_full_path;
private static ThumbRespeaker ref;
}
......@@ -114,7 +114,7 @@ public class ThresholdSpeechAnalyzer extends Analyzer {
* to speech in this Analyzer?
* @param recognizer A silence/audio recognizer.
*/
public ThresholdSpeechAnalyzer(int silenceTriggerAmount, int speechTriggerAmount, Recognizer recognizer) {
public ThresholdSpeechAnalyzer(int silenceTriggerAmount, int speechTriggerAmount, Recognizer recognizer) {
this.silenceTriggerAmount = silenceTriggerAmount;
this.speechTriggerAmount = speechTriggerAmount;
......@@ -188,8 +188,7 @@ public class ThresholdSpeechAnalyzer extends Analyzer {
// Add the copied current buffer onto the end.
//
for(int i = 0; i < buffer.length; i++)
afterBuffer[i + offset] = copiedBuffer[i];
System.arraycopy(copiedBuffer, 0, afterBuffer, offset, buffer.length);
}
//TODO Duplicate method. See addToAfterBuffer.
......@@ -211,8 +210,7 @@ public class ThresholdSpeechAnalyzer extends Analyzer {
// Add the copied current buffer onto the end.
//
for(int i = 0; i < buffer.length; i++)
onsetBuffer[i + offset] = copiedBuffer[i];
System.arraycopy(copiedBuffer, 0, onsetBuffer, offset, buffer.length);
}
/** Clear the before speech buffer. */
......@@ -265,12 +263,10 @@ public class ThresholdSpeechAnalyzer extends Analyzer {
// Clear onset buffer.
clearOnsetBuffer();
} else { // Still in silence mode.
// Remember n "silent" buffers to add before speech, always.
//
if(onsetBuffer.length < (buffer.length * ONSET_BUFFERS)) addToOnsetBuffer(buffer);
else shiftOnsetBufferWith(buffer);
}
} else if(onsetBuffer.length < (buffer.length * ONSET_BUFFERS))
addToOnsetBuffer(buffer);
else
shiftOnsetBufferWith(buffer);
}
}
......
package org.getalp.ligaikuma.lig_aikuma.model;
import android.util.Log;
import org.apache.commons.io.filefilter.IOFileFilter;
import org.getalp.ligaikuma.lig_aikuma.util.FileIO;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class CheapMapper
{
public static String TAG = "CheapMapper";
private String _currentSegment;
private String _bufferMap;
private int _nbBreakpoint;
private static CheapMapper _instance = null;
private CheapMapper()
{
_currentSegment="";
_bufferMap="";
_nbBreakpoint=0;
}
public static CheapMapper getInstance()
{
if(_instance==null) _instance = new CheapMapper();
return _instance;
}
public void addBreakpoint(String value)
{
Log.d(TAG, "addBreakpoint._nbBreakpoint: "+_nbBreakpoint);
switch(_nbBreakpoint)
{
case 0: _currentSegment=value+","; break;
case 1: _currentSegment+=value+":"; break;
case 2: _currentSegment+=value+","; break;
case 3: _currentSegment+=value; break;
}
_nbBreakpoint++;
}
public boolean canPushOnBuffer()
{
return _nbBreakpoint>3;
}
public void pushOnBuffer()
{
Log.d(TAG, "pushOnBuffer called: "+_currentSegment);
if(!canPushOnBuffer()) return;
_bufferMap+=_currentSegment+"\n";
_currentSegment="";
_nbBreakpoint=0;
Log.d(TAG, "pushOnBuffer on buffer: "+_bufferMap);
}
public boolean writeBuffer(File f)
{
try {
FileIO.write(f, _bufferMap);
} catch (IOException ignored)
{return false;}
return true;
}
public boolean LoadMap(File f)
{
try {
_bufferMap = FileIO.read(f);
} catch (IOException e) {
_bufferMap = "";
return false;
}
return true;
}
public void resetSegment() {_currentSegment="";_nbBreakpoint=0;}
public void resetBuffer() {_bufferMap="";}
}
\ No newline at end of file
......@@ -72,8 +72,8 @@ public class FileModel implements Parcelable {
String[] splitCloudId = cloudIdentifier.split("\\/");
int index = splitCloudId[6].lastIndexOf('.');
String fileName = splitCloudId[6].substring(0, index);
String ext = splitCloudId[6].substring(index+1);
String fileName = splitCloudId[6].substring(0, index),
ext = splitCloudId[6].substring(index+1);
switch (ext) {
case "json": //metadata
......
......@@ -183,9 +183,9 @@ public class Language implements Parcelable, Comparable<Language> {
* otherwise.
*/
public boolean equals(Object obj) {
if (obj == null || obj.getClass() != getClass())
if(obj == null || obj.getClass() != getClass())
return false;
if (obj == this)
if(obj == this)
return true;
Language rhs = (Language) obj;
return new EqualsBuilder().append(name, rhs.name).append(code, rhs.code).isEquals();
......
......@@ -166,9 +166,9 @@ public class RecordingLig extends Recording {
File destFile = new File(getIndividualRecordingPath(), this.name + MAP_EXT);
if(BuildConfig.DEBUG)Log.i(TAG, "importmapping - dest file: " + destFile.getAbsolutePath());
FileUtils.moveFile(mapFile, destFile);
FileUtils.moveFile(new File(FileIO.getNoSyncPath(), "tmp_no_speak"+MAP_EXT),
new File(getIndividualRecordingPath(), this.name + "_no_speak" + MAP_EXT));
if(BuildConfig.DEBUG)Log.i(TAG, "mapping file " + mapFile.getAbsolutePath() + " moves to " + destFile.getAbsolutePath());
File f = new File(FileIO.getNoSyncPath(), "tmp_no_speech"+MAP_EXT);
if(f.exists()) FileUtils.moveFile(f, new File(getIndividualRecordingPath(), this.name + "_no_speech" + MAP_EXT));
}
......
......@@ -47,10 +47,9 @@ public class ServerCredentials {
* @throws IOException If the credentials cannot be written.
*/
public void write() throws IOException {
JSONObject encodedServerCredentials = this.encode();
FileIO.writeJSONObject(
new File(FileIO.getAppRootPath(), "server_credentials.json"),
encodedServerCredentials);
this.encode());
}
/**
......@@ -63,14 +62,12 @@ public class ServerCredentials {
public static ServerCredentials read() throws IOException {
JSONObject encodedServerCredentials = FileIO.readJSONObject(
new File(FileIO.getAppRootPath(), "server_credentials.json"));
String ipAddress = (String) encodedServerCredentials.get("ipAddress");
String username = (String) encodedServerCredentials.get("username");
String password = (String) encodedServerCredentials.get("password");
Boolean syncActivated = (Boolean)
encodedServerCredentials.get("syncActivated");
String lastSyncDate = (String) encodedServerCredentials.get("lastSyncDate");
return new ServerCredentials(
ipAddress, username, password, syncActivated, lastSyncDate);
(String) encodedServerCredentials.get("ipAddress"),
(String) encodedServerCredentials.get("username"),
(String) encodedServerCredentials.get("password"),
(Boolean) encodedServerCredentials.get("syncActivated"),
(String) encodedServerCredentials.get("lastSyncDate"));
}
// Encodes the server credentials as a JSON object.
......@@ -102,18 +99,15 @@ public class ServerCredentials {
//Sets the IP address but will only accept valid IPv4 addresses.
private void setIPAddress(String ipAddress) {
Pattern pattern = Pattern.compile(IP_ADDRESS_PATTERN);
Matcher matcher = pattern.matcher(ipAddress);
if (matcher.matches()) {
if(Pattern.compile(IP_ADDRESS_PATTERN).matcher(ipAddress).matches())
this.ipAddress = ipAddress;
} else {
else
throw new IllegalArgumentException("Invalid IP Address");
}
}
// Sets the username, but will not accept empty strings.
private void setUsername(String username) {
if (username.compareTo("") != 0)
if(username.compareTo("") != 0)
this.username = username;
else
throw new IllegalArgumentException("username cannot be an empty string");
......
......@@ -23,15 +23,6 @@ public class TempTranscript {
// The recording the transcript is of. Needed to obtain the sample rate.
private Recording recording;
/**
* Constructor for an empty transcript.
*/
// Never Use
public TempTranscript() {
transcriptMap = new LinkedHashMap<Segment, TranscriptPair>();
}
/**
* Constructor
*
......@@ -53,9 +44,7 @@ public class TempTranscript {
*/
private void parseFile(File transcriptFile) throws IOException {
boolean firstSegment = true;
String data = FileIO.read(transcriptFile);
String[] lines = data.split("\n");
String[] splitLine;
String data = FileIO.read(transcriptFile), lines[] = data.split("\n"), splitLine[];
for (String line : lines) {
if (!line.startsWith(";;")) {
splitLine = line.split("\t");
......@@ -67,22 +56,19 @@ public class TempTranscript {
secondsToSample(Float.parseFloat(splitLine[0]))),
new TranscriptPair("",""));
}
if(BuildConfig.DEBUG)Log.i(TAG, "start sample: " +
secondsToSample(Float.parseFloat(splitLine[0])));
if(BuildConfig.DEBUG)Log.i(TAG, "end sample: " +
secondsToSample(Float.parseFloat(splitLine[1])));
if(BuildConfig.DEBUG)Log.i(TAG, "text: " + splitLine[3]);
if (splitLine.length > 4) {
if(BuildConfig.DEBUG){Log.i(TAG, "start sample: " + secondsToSample(Float.parseFloat(splitLine[0])));
Log.i(TAG, "end sample: " + secondsToSample(Float.parseFloat(splitLine[1])));
Log.i(TAG, "text: " + splitLine[3]);}
if (splitLine.length > 4)
transcriptMap.put(new Segment(
secondsToSample(Float.parseFloat(splitLine[0])),
secondsToSample(Float.parseFloat(splitLine[1]))),
new TranscriptPair(splitLine[3], splitLine[4]));
} else {
else
transcriptMap.put(new Segment(
secondsToSample(Float.parseFloat(splitLine[0])),
secondsToSample(Float.parseFloat(splitLine[1]))),
new TranscriptPair(splitLine[3], ""));
}
}
}
}
......@@ -94,20 +80,6 @@ public class TempTranscript {
return (long) (seconds * recording.getSampleRate());
}
/*
private void genDummyMap() {
transcriptMap.put(new Segment(0l, 49264l), "first shhh");
transcriptMap.put(new Segment(49264l, 109728l), "second shhh");
transcriptMap.put(new Segment(109728l, 142496l), "third shhh");
}
*/
/*
private Iterator<Segment> getSegmentIterator() {
return transcriptMap.keySet().iterator();
}
*/
public List<Segment> getSegmentList() {
return new ArrayList<Segment>(transcriptMap.keySet());
}
......@@ -131,10 +103,9 @@ public class TempTranscript {
* present
*/
public Segment getSegmentOfSample(long sample) {
for (Segment segment : getSegmentList()) {
if (sample >= segment.getStartSample() && sample <= segment.getEndSample())
for (Segment segment : getSegmentList())
if(sample >= segment.getStartSample() && sample <= segment.getEndSample())
return segment;
}
return getSegmentList().get(0);
}
......@@ -159,49 +130,4 @@ public class TempTranscript {
this.translation = translation;
}
}
/*
public void readSegments(File path) {
List<String> translation = new ArrayList<String>();
try {
CSVReader reader = new CSVReader(new FileReader(transFile), '\t');
String[] nextLine;
try {
//Skip the header.
reader.readNext();
reader.readNext();
while ((nextLine = reader.readNext()) != null) {
if(BuildConfig.DEBUG)Log.i("transcription", nextLine[0] + " " + nextLine[3]);
translation.add(nextLine[4]);
}
} catch (IOException e) {
//Translation doesn't exist maybe?
}
} catch (FileNotFoundException e) {
//File couldn't be found. We just get an empty list.
}
if(BuildConfig.DEBUG)Log.i("transcription", " " + translation);
return translation;
}
*/
/* *
* Returns a list of Strings corresponding to the segment-by-segment
* translation of the recording.
*/
/*
public List<String> getTranslation() {
List<Recording> respeakings = getRespeakings();
File transFile;
for (Recording respeaking : respeakings) {
transFile = new File(getRecordingsPath(),
respeaking.getUUID() + ".trans");