Commit
·
326b922
1
Parent(s):
89d79c0
file ids - transcriptions
Browse files- peoples_speech-clean.py +8 -11
peoples_speech-clean.py
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
-
|
15 |
import json
|
16 |
import os
|
17 |
|
@@ -72,9 +72,9 @@ _N_SHARDS_URL = _BASE_URL + "n_shards.json"
|
|
72 |
# relative path to metadata inside dataset's repo
|
73 |
_MANIFEST_URL = _BASE_URL + "{split}/{config}.json"
|
74 |
|
75 |
-
_WHISPER_TRANSCRIPT_URL = "https://huggingface.co/datasets/distil-whisper/
|
76 |
|
77 |
-
_WHISPER_TRANSCRIPT_URLs = _WHISPER_TRANSCRIPT_URL + "/{split}-transcription.
|
78 |
|
79 |
|
80 |
class PeoplesSpeechConfig(datasets.BuilderConfig):
|
@@ -222,13 +222,11 @@ class PeoplesSpeech(datasets.GeneratorBasedBuilder):
|
|
222 |
"duration_ms": duration
|
223 |
}
|
224 |
|
225 |
-
|
226 |
-
|
227 |
with open(whisper_transcript, encoding="utf-8") as f:
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
idx = 0
|
232 |
|
233 |
|
234 |
for local_extracted_archive_path, archive in zip(local_extracted_archive_paths, archives):
|
@@ -244,6 +242,5 @@ class PeoplesSpeech(datasets.GeneratorBasedBuilder):
|
|
244 |
"audio": {"path": path, "bytes": audio_file.read()},
|
245 |
"text": meta[audio_filename]["text"],
|
246 |
"duration_ms": meta[audio_filename]["duration_ms"],
|
247 |
-
"whisper_transcript":
|
248 |
}
|
249 |
-
idx += 1
|
|
|
11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
# See the License for the specific language governing permissions and
|
13 |
# limitations under the License.
|
14 |
+
import csv
|
15 |
import json
|
16 |
import os
|
17 |
|
|
|
72 |
# relative path to metadata inside dataset's repo
|
73 |
_MANIFEST_URL = _BASE_URL + "{split}/{config}.json"
|
74 |
|
75 |
+
_WHISPER_TRANSCRIPT_URL = "https://huggingface.co/datasets/distil-whisper/whisper_transcriptions_greedy/resolve/main/peoples_speech-clean"
|
76 |
|
77 |
+
_WHISPER_TRANSCRIPT_URLs = _WHISPER_TRANSCRIPT_URL + "/{split}-transcription.csv"
|
78 |
|
79 |
|
80 |
class PeoplesSpeechConfig(datasets.BuilderConfig):
|
|
|
222 |
"duration_ms": duration
|
223 |
}
|
224 |
|
225 |
+
whisper_transcriptions = dict()
|
|
|
226 |
with open(whisper_transcript, encoding="utf-8") as f:
|
227 |
+
reader = csv.DictReader(f, delimiter=",", quoting=csv.QUOTE_NONE)
|
228 |
+
for line in tqdm(reader, desc="Reading transcriptions..."):
|
229 |
+
whisper_transcriptions[line["file_id"]] = line["whisper_transcript"]
|
|
|
230 |
|
231 |
|
232 |
for local_extracted_archive_path, archive in zip(local_extracted_archive_paths, archives):
|
|
|
242 |
"audio": {"path": path, "bytes": audio_file.read()},
|
243 |
"text": meta[audio_filename]["text"],
|
244 |
"duration_ms": meta[audio_filename]["duration_ms"],
|
245 |
+
"whisper_transcript": whisper_transcriptions.get(audio_filename, None),
|
246 |
}
|
|