But for shorter files, you can add your media to a google cloud storage and run google cloud STT inside a cloud function and save the result to firestore.
// Goolge App Engine calls STT SDK// this function returns null.exports.createTranscript =functions.firestore.document("transcripts/{transcriptId}").onCreate(async (change, context) => {// Get an object representing the documentconstnewValue=change.data();// for now only run STT for uploaded files// eg if running from STT then don't run thisif (newValue.transcriptionType ==="upload") {// access a particular field as you would any JS propertyconststorageRef=newValue.storageRef;console.log("storageRef", storageRef);// https://firebase.google.com/docs/storage/admin/startconststorage=admin.storage();// https://github.com/firebase/firebase-tools/issues/1573#issuecomment-517000981constbucket=storage.appInternal.options.storageBucket;// // const gcsUri = 'gs://my-bucket/audio.raw';constgcsUri=`gs://${bucket}/${storageRef}`;console.log("gcsUri", gcsUri);//////// STT ////////// Creates a client for STTconstclient=newspeech.SpeechClient();constencoding="mp3"; //'Encoding of the audio file, e.g. LINEAR16';constsampleRateHertz="48000"; //16000;// const languageCode = newValue.language.value;constlanguageCode="en-US"; //'BCP-47 language code, e.g. en-US';constconfig= { encoding: encoding, sampleRateHertz: sampleRateHertz, languageCode: languageCode };constaudio= { uri: gcsUri };constrequest= { config: config, audio: audio };// // Detects speech in the audio file. This creates a recognition job that you// // can wait for now, or get its result later.const [operation] =awaitclient.longRunningRecognize(request);// Get a Promise representation of the final result of the jobconst [response] =awaitoperation.promise();// TODO: Convert to DPE// TODO: Save DPE json format to firebase as collection// get text - tmpconsttranscription=response.results.map(result =>result.alternatives[0].transcript).join("\n");console.log(`Transcription: ${transcription}`);// Then return a promise of a set operation to update the documentreturnchange.ref.set( {// TODO: change transcription to transcript transcription: transcription }, { merge:true } ); } else {returnnull; } });