Pre-fetch realistic voice only if user is opted in
This commit is contained in:
@ -11,6 +11,7 @@ import { google } from '@google-cloud/tasks/build/protos/protos'
|
||||
import { IntegrationType } from '../entity/integration'
|
||||
import { promisify } from 'util'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
import { signFeatureToken } from '../services/features'
|
||||
import View = google.cloud.tasks.v2.Task.View
|
||||
|
||||
const logger = buildLogger('app.dispatch')
|
||||
@ -347,6 +348,8 @@ export const enqueueTextToSpeech = async ({
|
||||
isUltraRealisticVoice = false,
|
||||
language,
|
||||
rate,
|
||||
featureName,
|
||||
grantedAt,
|
||||
}: {
|
||||
userId: string
|
||||
speechId: string
|
||||
@ -360,6 +363,8 @@ export const enqueueTextToSpeech = async ({
|
||||
isUltraRealisticVoice?: boolean
|
||||
language?: string
|
||||
rate?: string
|
||||
featureName?: string
|
||||
grantedAt?: Date | null
|
||||
}): Promise<string> => {
|
||||
const { GOOGLE_CLOUD_PROJECT } = process.env
|
||||
const payload = {
|
||||
@ -372,11 +377,7 @@ export const enqueueTextToSpeech = async ({
|
||||
language,
|
||||
rate,
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
const token = await signToken({ uid: userId }, env.server.jwtSecret, {
|
||||
expiresIn: '1h',
|
||||
})
|
||||
const token = signFeatureToken({ name: featureName, grantedAt }, userId)
|
||||
const taskHandlerUrl = `${env.queue.textToSpeechTaskHandlerUrl}?token=${token}`
|
||||
// If there is no Google Cloud Project Id exposed, it means that we are in local environment
|
||||
if (env.dev.isLocal || !GOOGLE_CLOUD_PROJECT) {
|
||||
|
||||
Reference in New Issue
Block a user