Cornish Text-to-Speech

The text-to-speech software espeak offers a basic text-to-speech utility in a variety of languages. I did at one point begin to develop a Cornish voice for espeak, but unfortunately lost this work along with my previous netbook. However, I have also used a simpler method which is to cheat by using espeak's Welsh language voice, and pre-format Cornish text by means of a Python script which simply performs a number of find-replace string operations, and a couple of shell scripts to run this and the espeak command itself in the Linux command-line. It is possible to use espeak in Windows as well. The scripts are available in my Github repository.

There are two shell scripts, kows_kernewek_speaker.sh and kows_kernewek_tofile.sh, the first of which takes a single argument which should be a file containing Cornish text (preferably in Kemmyn, though results for SWF should be reasonably OK). This will call espeak sending output to the computer's audio output. Alternatively, kows_kernewek_tofile.sh takes two arguments, the first containing Cornish text, the second the filename of an audio file to save the output to.

Both of these will use the Python module kernewek_to_welshorthography.py which does a number of string replace operations on the text to make it suitable to be processed by the espeak Welsh voice. This will replace Cornish dh with the Welsh equivalent for that phoneme, dd. The program does not actually produce something that would be orthographically correct in Welsh, for instance k in Cornish is left alone, since it makes no difference to the output of espeak. However ch which in Cornish represents the same sound as in English, represents a different phoneme in Welsh, so it is altered to tsi. Therefore, Fordh Chili in Cornish (Chili Road), becomes Ffordd Tsiili for the purposes of espeak.

Gorhemmyn

This program greets the user in Cornish, with an appropriate greeting for the time of day according to the system clock.

# gorhemmyn_kw.py
# David Trethewey
# 11-07-2015 
# skrifys rag #speakcornish week 2015
import time
import os
import kernewek_to_welshorthography
class Gorhemmyn:
    # py termynyow a wra chanjya 
    # furv an gorhemmynadow
    bora = 3
    myttin = 7
    dydh = 11
    dohajydh = 14
    gorthugher = 18
    nos = 23
    def __init__(self):
        t = time.localtime()
        our = t.tm_hour
        self.gorhemmyn = "Dydh da" # default
        if our >= Gorhemmyn.nos or our < Gorhemmyn.bora:
            self.gorhemmyn = "Nos da"
        if our >= Gorhemmyn.bora and our < Gorhemmyn.myttin:
            self.gorhemmyn = "Bora da"
        if our >= Gorhemmyn.myttin and our < Gorhemmyn.dydh:
            self.gorhemmyn = "Myttin da"
        if our >= Gorhemmyn.dydh and our < Gorhemmyn.dohajydh:
            self.gorhemmyn = "Dydh da"
        if our >= Gorhemmyn.dohajydh and our < Gorhemmyn.gorthugher:
            self.gorhemmyn = "Dohajydh da"
        if our >= Gorhemmyn.gorthugher and our < Gorhemmyn.nos:
            self.gorhemmyn = "Gorthugher da"

    def pryntya(self):
        print(self.gorhemmyn)

    def kewsel(self):
        tekst_cy = kernewek_to_welshorthography.towelsh([self.gorhemmyn])
        # print(tekst_cy)
        espeakcmd = 'espeak -vcy \"{t}\"'.format(t=tekst_cy)
        #print(espeakcmd)
        os.system(espeakcmd)
        
if __name__ == "__main__":
    g = Gorhemmyn()
    g.pryntya()
    g.kewsel()
    

Graphical Frontend

I have now written a graphical frontend to this, which is written using the Tkinter library.
The Cornish text is input in the white box, and then the 'Kewsel' button clicked, to call espeak to speak the phrase. Alternatively, 'Gorhemmyn' chooses a greeting according to the system clock.