This application aims to aid language learning by turning subtitle files into a learning plan!
It works by taking an uploaded text file, parsing it, and sending a request to an internal translation API
The app then displays translations records in several formats
In this mode the user sees a translation. They can "flip" it to see the translation in their base language. They can also play the translation with the press of the "Play Translation" button which makes a call to OpenAi's text-to-speech API.
In multiple choice mode the user is given a translation in their target language and they are tasked with selecting the correct translation in their base language from the dropdown list
This function works by making a call to OpenAi's tts API and handling the response with jquery. This is a very neat feature, and everyone should make sure to check it out!
A user uploads a file and a call is made to the perform function in the app/jobs/parse_file_to_database.rb file. that function parses the file line by line and makes requests to the translation service
Upon success the translation service responds with the translation in the requested language. This translation, along with the original line is committed to a new Translation model record
After some time there can be an intermittent PG::BAD_CONNECTION error, so there is retry logic in place in the perform function to make the job picks up where it left off in the event of this error.
These records can be viewed in the translation mode, multiple choice mode and "need to review" views.
- app/views/homepage/: the views for the instructions and landing pages
- app/views/learning_paths/: views related to the main view
- app/views/translations/: views related to individual translations
- app/views/flashcards/: Views related to the multiple choice mode and translation mode
Logic related to what is displayed can generally be found in the controllers section
The tts controller contains a function responsible for making requests to Openai and sending the received binary file to the view where the file is assigned to a (jquery) blob and played immediately