Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

988 B
Raw Blame
import type { SpeechToTextTarget } from './types'
import { audioToText } from '@/service/share'

export async function transcribeAudio(
  target: SpeechToTextTarget,
  file: File,
  signal?: AbortSignal,
): Promise<{ text: string }> {
  if (target.type === 'agent' || target.type === 'consoleApp') {
    const { consoleClient } = await import('@/service/console')
    if (target.type === 'agent') {
      return consoleClient.agent.byAgentId.audioToText.post(
        {
          body: {
            draft_type: target.draftType,
            file,
          },
          params: {
            agent_id: target.agentId,
          },
        },
        { signal },
      )
    }
    return consoleClient.apps.byAppId.audioToText.post(
      {
        body: { file },
        params: { app_id: target.appId },
      },
      { signal },
    )
  }

  const formData = new FormData()
  formData.append('file', file)
  return audioToText(target.appSourceType, target.appId, formData, signal)
}