Search code examples
pythontkintercharacter-encodingspeech-recognitionunicode-string

Unicode to Kruti Dev 010


How to convert unicode to Kruti Dev 010?

I'm using python speech recognition library to convert speech to text and displaying it using tkinter Text widget but it's not displaying in 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,' ')

Also, on saving the file speech recognized text is not saving however typed text is saving.

KrutiDev to Unicode Converter.


Solution

  • I'm not familiar enough with either tkinter or devanagari to tell whether this is at all helpful, but I found another project with a pair of functions which map both ways; is this what you are looking for?

    The code at https://github.com/jmcmanu2/python_practice/blob/master/Unicode%20KrutiDev%20converter.py doesn't have an explicit license, so I am not comfortable publishing it here, but I have a slightly updated version for Python 3 in a gist at https://gist.github.com/tripleee/b82a79f5b3e57dc6a487ae45077cdbd3 for the time being. (The original was almost Python 3 already so the tweaking required was minimal, though I ripped out unrelated parts which dealt with Excel files.)

    With that code available as an import, does this do what you are asking?

    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)