Skip to content

Commit

Permalink
Stay on same dataset after labelling clip
Browse files Browse the repository at this point in the history
  • Loading branch information
BenAAndrew committed Oct 16, 2021
1 parent 9ed661e commit 2b23625
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
32 changes: 17 additions & 15 deletions application/static/manage-datasets.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{% extends "simplebase.html" %}
{% block content %}
<script src="{{ url_for('static', filename='manage-datasets.js') }}"></script>
<h2>Manage datasets</h2>
<br>
<form method="POST" action="/label-clip">
<div class="form-group">
<select class="form-control" id="dataset" name="dataset" onchange="selectDataset()">
{% for dataset in datasets %}
<option value="{{dataset}}">{{dataset}}</option>
<option value="{{dataset}}" {% if selected == dataset %}selected{% endif %}>{{dataset}}</option>
{% endfor %}
</select>
</div>
Expand Down Expand Up @@ -39,23 +38,26 @@ <h5>Words</h5>
</div>
<div class="col-md">
<h2>Label clips</h2>
<p>Label clips that the dataset generator couldn't</p>
<div class="form-group">
<select class="form-control" id="unlabelled_clip" name="unlabelled_clip" onchange="selectUnlabelledClip()"></select>
</div>
<div class="form-group">
<audio controls id="audio">
<source id="audioSource" type="audio/wav">
</audio>
<p id="label-clip-message"></p>
<div id="label-clip" style="display: none;">
<div class="form-group">
<select class="form-control" id="unlabelled_clip" name="unlabelled_clip" onchange="selectUnlabelledClip()"></select>
</div>
<div class="form-group">
<audio controls id="audio">
<source id="audioSource" type="audio/wav">
</audio>
</div>
<div class="form-group">
<label for="sentence"><a href="#" data-toggle="tooltip" data-placement="top" title="What is said in the audio (make sure to use punctuation)">Text</a></label>
<input type="text" id="sentence" name="sentence" class="form-control" required>
</div>
<input type="submit" class="btn btn-primary">
</div>
<div class="form-group">
<label for="sentence"><a href="#" data-toggle="tooltip" data-placement="top" title="What is said in the audio (make sure to use punctuation)">Text</a></label>
<input type="text" id="sentence" name="sentence" class="form-control" required>
</div>
<input type="submit" class="btn btn-primary">
</div>
</div>
</div>
</form>

<script src="{{ url_for('static', filename='manage-datasets.js') }}"></script>
{% endblock %}
5 changes: 5 additions & 0 deletions application/static/manage-datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@ function selectDataset(){
j = JSON.parse(this.response);
var clips = j.unlabelled;
if(clips.length > 0) {
document.getElementById("label-clip-message").innerHTML = "Label clips that the dataset generator couldn't";
document.getElementById("label-clip").style.display = "block";
for(let i = 0; i < clips.length; i++){
option = document.createElement("option");
option.value = clips[i];
option.text = clips[i];
select.appendChild(option);
}
selectUnlabelledClip();
} else {
document.getElementById("label-clip-message").innerHTML = "No clips to label";
document.getElementById("label-clip").style.display = "none";
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion application/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def manage_datasets():
return render_template(
"manage-datasets.html",
datasets=os.listdir(paths["datasets"]),
selected=request.values.get("dataset")
)


Expand Down Expand Up @@ -377,7 +378,7 @@ def label_clip():
os.path.join(paths["datasets"], dataset, AUDIO_FOLDER, clip),
)

return redirect("/manage-datasets")
return redirect(f"/manage-datasets?dataset={dataset}")


# Import-export
Expand Down

0 comments on commit 2b23625

Please sign in to comment.