Datasets:
michaelnetbiz
commited on
Commit
•
d20c778
1
Parent(s):
3293e45
Text cleaning
Browse files
.run/{prep_data.run.xml → prep_push_to_hf.run.xml}
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
<component name="ProjectRunConfigurationManager">
|
2 |
-
<configuration default="false" name="prep_push_to_hf" type="PythonConfigurationType" factoryName="Python"
|
3 |
<module name="Kendex" />
|
4 |
<option name="INTERPRETER_OPTIONS" value="" />
|
5 |
<option name="PARENT_ENVS" value="true" />
|
@@ -7,7 +7,7 @@
|
|
7 |
<env name="PYTHONUNBUFFERED" value="1" />
|
8 |
</envs>
|
9 |
<option name="SDK_HOME" value="" />
|
10 |
-
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/
|
11 |
<option name="IS_MODULE_SDK" value="true" />
|
12 |
<option name="ADD_CONTENT_ROOTS" value="true" />
|
13 |
<option name="ADD_SOURCE_ROOTS" value="true" />
|
@@ -31,7 +31,7 @@
|
|
31 |
<option name="region" />
|
32 |
<option name="useCurrentConnection" value="false" />
|
33 |
</EXTENSION>
|
34 |
-
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/
|
35 |
<option name="PARAMETERS" value="" />
|
36 |
<option name="SHOW_COMMAND_LINE" value="false" />
|
37 |
<option name="EMULATE_TERMINAL" value="false" />
|
|
|
1 |
<component name="ProjectRunConfigurationManager">
|
2 |
+
<configuration default="false" name="prep_push_to_hf" type="PythonConfigurationType" factoryName="Python">
|
3 |
<module name="Kendex" />
|
4 |
<option name="INTERPRETER_OPTIONS" value="" />
|
5 |
<option name="PARENT_ENVS" value="true" />
|
|
|
7 |
<env name="PYTHONUNBUFFERED" value="1" />
|
8 |
</envs>
|
9 |
<option name="SDK_HOME" value="" />
|
10 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/kendex" />
|
11 |
<option name="IS_MODULE_SDK" value="true" />
|
12 |
<option name="ADD_CONTENT_ROOTS" value="true" />
|
13 |
<option name="ADD_SOURCE_ROOTS" value="true" />
|
|
|
31 |
<option name="region" />
|
32 |
<option name="useCurrentConnection" value="false" />
|
33 |
</EXTENSION>
|
34 |
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/kendex/prep_push_to_hf.py" />
|
35 |
<option name="PARAMETERS" value="" />
|
36 |
<option name="SHOW_COMMAND_LINE" value="false" />
|
37 |
<option name="EMULATE_TERMINAL" value="false" />
|
kendex/prep_push_to_hf.py
CHANGED
@@ -22,6 +22,12 @@ def text_filter(item):
|
|
22 |
return MIN_LEN < len([i for i in item.split(" ") if len(i) > 0]) < MAX_LEN
|
23 |
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
def create_dataset(item):
|
26 |
dataset = Dataset.from_pandas(item)
|
27 |
dataset = dataset.cast_column("audio", Audio(sampling_rate=16_000))
|
@@ -42,7 +48,6 @@ def main():
|
|
42 |
"audio": wavs,
|
43 |
"file": [basename(w) for w in wavs],
|
44 |
"text": metadata[1],
|
45 |
-
"norm": metadata[1].map(lambda x: normalize(x)),
|
46 |
"duration": [librosa.get_duration(path=w) for w in wavs],
|
47 |
}
|
48 |
|
@@ -51,7 +56,9 @@ def main():
|
|
51 |
train, test = np.split(df, [int(0.9 * len(df))])
|
52 |
|
53 |
train_dataset = create_dataset(train)
|
|
|
54 |
test_dataset = create_dataset(test)
|
|
|
55 |
|
56 |
full_dataset = DatasetDict({"train": train_dataset, "test": test_dataset})
|
57 |
full_dataset.push_to_hub("michaelnetbiz/Kendex")
|
|
|
22 |
return MIN_LEN < len([i for i in item.split(" ") if len(i) > 0]) < MAX_LEN
|
23 |
|
24 |
|
25 |
+
def text_mapper(item):
|
26 |
+
text = item["text"]
|
27 |
+
item["normalized_text"] = normalize(text)
|
28 |
+
return item
|
29 |
+
|
30 |
+
|
31 |
def create_dataset(item):
|
32 |
dataset = Dataset.from_pandas(item)
|
33 |
dataset = dataset.cast_column("audio", Audio(sampling_rate=16_000))
|
|
|
48 |
"audio": wavs,
|
49 |
"file": [basename(w) for w in wavs],
|
50 |
"text": metadata[1],
|
|
|
51 |
"duration": [librosa.get_duration(path=w) for w in wavs],
|
52 |
}
|
53 |
|
|
|
56 |
train, test = np.split(df, [int(0.9 * len(df))])
|
57 |
|
58 |
train_dataset = create_dataset(train)
|
59 |
+
train_dataset = train_dataset.map(text_mapper)
|
60 |
test_dataset = create_dataset(test)
|
61 |
+
test_dataset = test_dataset.map(text_mapper)
|
62 |
|
63 |
full_dataset = DatasetDict({"train": train_dataset, "test": test_dataset})
|
64 |
full_dataset.push_to_hub("michaelnetbiz/Kendex")
|