| --- |
| license: apache-2.0 |
| --- |
| |
| Data checkpoints from https://github.com/hexgrad/misaki for Grapheme To Phoneme (G2P) conversion. |
|
|
|
|
| ## Code to generate: |
| ```py |
| !git clone https://github.com/hexgrad/misaki |
| %cd misaki |
| |
| import subprocess |
| import json |
| import pandas as pd |
| from misaki import __version__ |
| |
| def get_git_commit_hash(): |
| result = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True, check=True) |
| return result.stdout.strip() |
| |
| def get_rows(data, language): |
| rows = [] |
| for key, values in data.items(): |
| if not isinstance(values, dict): |
| values = dict(DEFAULT=values) |
| for pos, phonemes in values.items(): |
| rows.append(dict( |
| language=language, |
| word=key, |
| pos=pos, |
| phonemes=phonemes, |
| )) |
| return rows |
| |
| dictionaries = ["us_gold", "us_silver", "gb_gold", "gb_silver"] |
| data = {} |
| for dictionary in dictionaries: |
| with open(f"./misaki/data/{dictionary}.json") as f: |
| data[dictionary] = json.load(f) |
| |
| rows = [] |
| for dictionary, data in data.items(): |
| rows.extend(get_rows(data, f"en-{'US' if dictionary.startswith('us_') else 'GB'}")) |
| |
| df = pd.DataFrame(rows) |
| commit_hash = get_git_commit_hash() |
| dataset_name = f"{__version__}-{commit_hash}.parquet" |
| df.to_parquet(dataset_name) |
| ``` |