diff --git a/OU Dictionary Editor/Assets/plugins/generate_yaml_template.py b/OU Dictionary Editor/Assets/plugins/generate_yaml_template.py index 8de8bfb..b3e43bb 100644 --- a/OU Dictionary Editor/Assets/plugins/generate_yaml_template.py +++ b/OU Dictionary Editor/Assets/plugins/generate_yaml_template.py @@ -22,7 +22,9 @@ def read_symbol_types_from_yaml(folder_path): if 'symbols' in data and isinstance(data['symbols'], list): # Ensure 'symbols' is in data and is a list for item in data['symbols']: if isinstance(item, dict) and 'symbol' in item and 'type' in item: - symbol_types[item['symbol']] = item['type'] + # Convert symbol to string to ensure consistency + symbol = str(item['symbol']) + symbol_types[symbol] = item['type'] else: print(f"Unexpected item format in {filename}: {item}") else: diff --git a/OU Dictionary Editor/OpenUtau_Dictionary_Editor.pyw b/OU Dictionary Editor/OpenUtau_Dictionary_Editor.pyw index 9741c0d..098faff 100644 --- a/OU Dictionary Editor/OpenUtau_Dictionary_Editor.pyw +++ b/OU Dictionary Editor/OpenUtau_Dictionary_Editor.pyw @@ -1645,19 +1645,21 @@ class Dictionary(TkinterDnD.Tk): # Read symbol types from YAML files symbol_types = read_symbol_types_from_yaml(TEMPLATES) # Set to keep track of already existing phonemes - existing_phonemes = {symbol['symbol'] for symbol in self.symbols_list} + existing_phonemes = {str(symbol['symbol']) for symbol in self.symbols_list} new_phonemes = [] - # Iterate through the dictionary to find unique phonemes + + # Iterate through the dictionary to find unique phonemes for grapheme, phonemes in self.dictionary.items(): for phoneme in phonemes: - if phoneme not in existing_phonemes: + phoneme_str = str(phoneme) # Convert phoneme to string + if phoneme_str not in existing_phonemes: # Determine the phoneme type, defaulting to 'unknown' if not found - phoneme_type = symbol_types.get(phoneme, 'unknown') - new_phonemes.append({'symbol': phoneme, 'type': phoneme_type, 'rename': ''}) - existing_phonemes.add(phoneme) + phoneme_type = symbol_types.get(phoneme_str, 'unknown') + new_phonemes.append({'symbol': phoneme_str, 'type': phoneme_type, 'rename': ''}) + existing_phonemes.add(phoneme_str) # Sort the new phonemes alphabetically by 'symbol' - new_phonemes_sorted = sorted(new_phonemes, key=lambda x: x['symbol']) + new_phonemes_sorted = sorted(new_phonemes, key=lambda x: str(x['symbol'])) # Add the sorted phonemes to symbols and symbols_list for phoneme_data in new_phonemes_sorted: @@ -1667,7 +1669,7 @@ class Dictionary(TkinterDnD.Tk): self.symbols_list.append(phoneme_data) # After adding, sort self.symbols_list alphabetically by 'symbol' to keep consistency - self.symbols_list = sorted(self.symbols_list, key=lambda x: x['symbol']) + self.symbols_list = sorted(self.symbols_list, key=lambda x: str(x['symbol'])) self.open_symbol_editor() def show_context_menu(self, event):