omnivore/packages/api/src/services/speech.ts
2023-04-18 11:22:44 +08:00

22 lines
614 B
TypeScript

import { Page, PageType } from '../elastic/types'
import { ContentReader } from '../generated/graphql'
import { contentReaderForPageType } from '../utils/uploads'
import { FeatureName, isOptedIn } from './features'
/*
* We should synthesize the page when user is opted in to the feature
*/
export const shouldSynthesize = async (
userId: string,
page: Page
): Promise<boolean> => {
if (
contentReaderForPageType(page.pageType) !== ContentReader.Web ||
!page.content
) {
// we don't synthesize files for now
return false
}
return isOptedIn(FeatureName.UltraRealisticVoice, userId)
}