> For the complete documentation index, see [llms.txt](https://textav.gitbook.io/firebase-react-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://textav.gitbook.io/firebase-react-notes/stt/stt-+-cloud-function-+-cloud-task/example-implementation.md).

# Example implementation

## High level overview

You'd need 2 cloud function, one (`createTranscript`)to start the recognition, and trigger a cloud task that on a time delay triggers the second one (`firestoreCheckSTT`)to check the progress of the transcription gcp operation. If the transcript is not done, it triggers another cloud task to re-trigger the second cloud task later.

![GCP STT + Cloud functions + Cloud Task](/files/-ML7zXT6vQ4KzwkdA_kD)

## Cloud Function `createTranscript`

* [ ] Create audio that meets GCP STT Specs \
  (eg `ogg` or `wav`.`ffmpeg` bin present on GCP Cloud function by default)
* [ ] &#x20;Call Google Cloud STT long running recognition
* [ ] Get operation name in response&#x20;
* [ ] Start cloud task (eg on a 5 min delay)
  * [ ] in cloud task payload have
    * operation name
    * firestore path to the audio file
  * [ ] cloud task end point for cloud function to check STT `firestoreCheckSTT`
  * [ ] add ENV for firebase to be able to call GCP STT opration
* [ ] save to firestorm&#x20;
  * operation name
  * status 'in-progress'
* [ ] return&#x20;

## Cloud function to check if operation is done `firestoreCheckSTT`

* [ ] end point for GCP operation
* [ ] GET request to check GCP operation end point   &#x20;
  * [ ] if done&#x20;
    * [ ] save data
  * [ ] if not done
    * [ ] trigger another cloud task operation&#x20;
    * [ ] same payload
  * [ ] if errors&#x20;
    * [ ] save data to firestore

missing handling edge cases, eg If the transcript has been deleted, should try to save in the cloud task, it should drop it Eg instead of set / merge should be try catch, with a method for update only if it exists


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://textav.gitbook.io/firebase-react-notes/stt/stt-+-cloud-function-+-cloud-task/example-implementation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
