Skip to content

QubitPi/aristotle

Repository files navigation

title emoji colorFrom colorTo sdk sdk_version app_file pinned license short_description
Aristotle
🏆
gray
green
gradio
5.1.0
app.py
false
apache-2.0
Ancient Greek text to audio

Aristotle

Python Version Badge Hugging Face space badge GitHub workflow status badge Hugging Face sync status badge Docker Hub Apache License Badge

Aristotle is an automatic text to speech application that takes an Ancient Greek excerpt as input and generates a downloadable audio for language learner for practice speaking in Ancient Greek. Aristotle generates speech using the OpenAI's text-to-speech API.

The app is available on Hugging Face space. Please check it out.

A Docker image is also available:

docker run -d --name aristotle -p 7860:7860 jack20191124/aristotle

When container is up and running, visit app at http://localhost:7860.

How Does It Work

Ancient Greek is a phonetically-lost language, because no one knows the correct pronunciation of such an ancient language. A lack of audio content is a major hurdle to learning Ancient Greek. So I decided to tackle this problem with NLP.

OpenAI will read Ancient Greek text with a modern Greek pronunciation. What's different about OpenAI from other Text-to-Speech tools is that OpenAI is unaffected by the different accents and breathing marks in Ancient Greek. It will simply read the Ancient Greek text in modern pronunciation with the accents in the right places. Studying Ancient Greeek with modern pronunciation is simply not satisfactory for me, though, so I started messing around with the text to see if I could get the pronunciation closer to Erasmian/Attic/whatever we want to call it. We can simply replace letters in the Greek words with Latin letters to try and get what we want.

Here is an example sentence.

This is the original text, which OpenAI will read in Modern Greek with no problem:

Σόλων ἦν συνετώτατος πάντων τῶν Ἀθηναίων, τὴν γὰρ σοφίαν αὐτοῦ οὐ μόνον οἱ πολῖται ἐθαύμαζον, ἀλλὰ καὶ οἱ ἂλλοι Ἓλληνες πάντες, πολλοὶ δὲ καὶ τῶν βαρβάρων.

And here is the same but with letters replaced to try and get OpenAI to read in an "Attic" pronunciation:

sόλωn en sunetώtαtος πάntωn tón aθenáiωn, tén γáρ sοφίan autu u μόnon hoi πολítαi eθáuμαζon, aλλá kái hoi áλλοi Héλλeneς πάnteς, πολλói δé kái tón βαρβάρωn.

A huge list of letter replacements has been made to try and imitate Attic pronunciation as closely as possible. The result is pretty solid and is close enough to be useful for creating audio files for texts where we don't have any audio recordings.

Development

Running Locally

git clone [email protected]:QubitPi/aristotle.git
cd aristotle

virtualenv .venv
source .venv/bin/activate
pip3 install -r requirements.txt

To start the app:

export SERVER_NAME=127.0.0.1
python3 app.py

The app will be available at http://localhost:7860 and the API docs at http://localhost:7860/?view=api

Docker

To build a Docker container of Aristotle, follow these steps:

  1. Make sure Docker has been installed

  2. Open a terminal and navigate to the project directory.

  3. Run the following command to build the Docker image:

    docker build -t jack20191124/aristotle .
    
  4. Wait for the build process to complete.

  5. Once the build is finished, we can run the Docker container using the following command:

    docker run -it --name aristotle -p 7860:7860 jack20191124/aristotle
  6. Open up browser and navigate to http://localhost:7860 to access the space.

Toubleshooting

No matching distribution found for fastapi While Executing pip3 install -r requirements.txt

This could be caused by one's proxy. Simply turn-off or switch proxy should work

License

The use and distribution terms for aristotle are covered by the Apache License, Version 2.0.