dylman123 / final-captions-pro

A MacOS app which automatically generates customisable open captions in Final Cut Pro X
1 stars 0 forks source link

uploadAudio() sometimes doesn't execute properly #26

Closed dylman123 closed 4 years ago

dylman123 commented 4 years ago

The app gets stuck at the semaphore.wait() line.

Intermittent. Probably something to do with threads.

dylman123 commented 4 years ago

Need to move away from the semaphore pattern. Look at using Combine's observable objects to manage the state of the backend flow.

Also need to use the @escaping closure for the uploadAudio function. May require nested closures. But this is OK. Although maybe Combine can avoid the need for nested closures...?

dylman123 commented 4 years ago

Plan to refactor backend functions

Ok, plan is: Use Jonny's enum state concept to define the following states for each function in the serialised generateCaptions() function:

  1. idle
  2. ready
  3. executing
  4. completed
  5. failed
dylman123 commented 4 years ago

image

dylman123 commented 4 years ago

Or maybe the states should simply be:

  1. extractAudio
  2. convertAudio
  3. uploadAudio
  4. downloadCaptions
  5. deleteTempDir
dylman123 commented 4 years ago

Look at how to convert JSON payload into custom struct type with modifications: https://www.hackingwithswift.com/example-code/system/how-to-parse-json-using-jsonserialization

dylman123 commented 4 years ago

Implemented Jonny's UserAPI state-based enums. Also needed to use recursion for short polling the server whilst waiting for transcriptions to finish. Will later need to open an issue to build a "silent notification" service to replace the short polling.