File size: 1,259 Bytes
8cf8015 | 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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ---
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)
``` |