forked from sarulab-speech/jtubespeech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_farsi.py
29 lines (24 loc) · 1023 Bytes
/
extract_farsi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python
# coding: utf-8
import os
import pandas as pd
import pyarrow.parquet as pq
from pathlib import Path
if __name__ == "__main__":
lang_dir = Path('/usr/local/corpus/fa')
subtitle_exists = pd.read_csv(str(lang_dir / 'fawiki-latest-pages-articles-multistream-index.csv'))
vids = set(subtitle_exists["videoid"])
print(len(subtitle_exists))
for i in (lang_dir / 'asr-farsi-youtube-chunked-30-seconds/data').iterdir():
print(i)
parquet_file = pq.ParquetFile(str(i))
data = parquet_file.read().to_pandas()
for index, row in data.iterrows():
vid = row['video_id']
if vid in vids:
continue
print(vid)
vids.add(vid)
subtitle_exists = pd.concat([subtitle_exists, pd.DataFrame([{"videoid": vid, "auto": True, "sub": True}])], ignore_index=True)
subtitle_exists.to_csv(str(lang_dir / 'fawiki-latest-pages-articles-multistream-index_.csv'), index=None)
print(len(subtitle_exists))