首页 > 解决方案 > Unicode 到 Kruti Dev 010

问题描述

如何将 unicode 转换为 Kruti Dev 010?

我正在使用 python 语音识别库将语音转换为文本并使用 tkinter Text 小部件显示它,但它没有在 Kruti Dev 中显示。

      # class variable 
      __thisTextArea = Text(__root)
      Font_tuple = font.Font(family='Kruti Dev 010', size=16)

      # inside constructor
      self.__thisTextArea.config(font = self.Font_tuple,   yscrollcommand=self.__thisScrollBar.set)
      
      # inside speech recognition function
      self.__thisTextArea.insert(INSERT, text_obtained)
      self.__thisTextArea.insert(END,' ')

此外,在保存文件时,语音识别的文本不会被保存,但输入的文本会被保存。

KrutiDev 到 Unicode 转换器。

标签: pythontkintercharacter-encodingspeech-recognitionunicode-string

解决方案


我对 tkinter 或 devanagari 都不够熟悉,无法判断这是否有帮助,但我发现了另一个项目,它有一对双向映射的函数;这是你想要的?

https://github.com/jmcmanu2/python_practice/blob/master/Unicode%20KrutiDev%20converter.py上的代码没有明确的许可证,所以我不喜欢在这里发布它,但我有一个稍微更新的版本暂时在https://gist.github.com/tripleee/b82a79f5b3e57dc6a487ae45077cdbd3上的 Python 3 的要点。(原来的版本几乎已经是 Python 3,因此所需的调整很少,尽管我删除了处理 Excel 文件的不相关部分。)

使用该代码作为import,这是否符合您的要求?

from unicode2krutidev import Unicode_to_KrutiDev

# ...

class something:
    __thisTextArea = Text(__root)
    Font_tuple = font.Font(family='Kruti Dev 010', size=16)

    def __init__(self, ...):
      # ...
      self.__thisTextArea.config(font = self.Font_tuple,   yscrollcommand=self.__thisScrollBar.set)
      # ...

    def recognize_speech(self, ...):
      # ...
      text_converted = Unicode_to_KrutiDev(text_obtained)
      self.__thisTextArea.insert(INSERT, text_converted)
      self.__thisTextArea.insert(END,' ')
      # ...
      self.save_to_database(text_obtained)

推荐阅读