Skip to content

Commit

Permalink
✨ feat: Add duplex to microsoft fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed Nov 15, 2023
1 parent 1a73072 commit 205d97b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
3 changes: 1 addition & 2 deletions api/edge-speech.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createEdgeSpeechComletion } from '../src/server/createEdgeSpeechComletion';
import { EdgeSpeechPayload } from '../src/server/types';
import { EdgeSpeechPayload, createEdgeSpeechComletion } from '@lobehub/tts';

export const config = {
runtime: 'edge',
Expand Down
3 changes: 1 addition & 2 deletions api/microsoft-speech.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createMicrosoftSpeechComletion } from '../src/server/createMicrosoftSpeechComletion';
import { MicrosoftSpeechPayload } from '../src/server/types';
import { MicrosoftSpeechPayload, createMicrosoftSpeechComletion } from '@lobehub/tts';

export const config = {
runtime: 'edge',
Expand Down
4 changes: 1 addition & 3 deletions api/open-stt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { OpenAISTTPayload, createOpenaiAudioTranscriptionsCompletion } from '@lobehub/tts';
import OpenAI from 'openai';

import { createOpenaiAudioTranscriptionsCompletion } from '../src/server/createOpenaiAudioTranscriptionsCompletion';
import { OpenAISTTPayload } from '../src/server/types';

export const config = {
runtime: 'edge',
};
Expand Down
4 changes: 1 addition & 3 deletions api/openai-tts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { OpenAITTSPayload, createOpenaiAudioSpeechCompletion } from '@lobehub/tts';
import OpenAI from 'openai';

import { createOpenaiAudioSpeechCompletion } from '../src/server/createOpenaiAudioSpeechCompletion';
import { OpenAITTSPayload } from '../src/server/types';

export const config = {
runtime: 'edge',
};
Expand Down
10 changes: 5 additions & 5 deletions src/server/createEdgeSpeechComletion.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import qs from 'query-string';
import { v4 as uuidv4 } from 'uuid';

import { EDGE_API_TOKEN, EDGE_SPEECH_URL } from '../const/api';
import { EdgeSpeechPayload } from '../server/types';
import { genSSML } from '../utils/genSSML';
import { genSendContent } from '../utils/genSendContent';
import { getHeadersAndData } from '../utils/getHeadersAndData';
import { EDGE_API_TOKEN, EDGE_SPEECH_URL } from '@/const/api';
import { EdgeSpeechPayload } from '@/server/types';
import { genSSML } from '@/utils/genSSML';
import { genSendContent } from '@/utils/genSendContent';
import { getHeadersAndData } from '@/utils/getHeadersAndData';

const configConent = JSON.stringify({
context: {
Expand Down
8 changes: 5 additions & 3 deletions src/server/createMicrosoftSpeechComletion.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { v4 as uuidv4 } from 'uuid';

import { MICROSOFT_SPEECH_URL } from '../const/api';
import { MicrosoftSpeechPayload } from '../server/types';
import { genSSML } from '../utils/genSSML';
import { MICROSOFT_SPEECH_URL } from '@/const/api';
import { MicrosoftSpeechPayload } from '@/server/types';
import { genSSML } from '@/utils/genSSML';

interface CreateMicrosoftSpeechComletionOptions {
payload: MicrosoftSpeechPayload;
Expand Down Expand Up @@ -41,6 +41,8 @@ export const createMicrosoftSpeechComletion = async ({

const res = await fetch(MICROSOFT_SPEECH_URL, {
body,
// @ts-ignore
duplex: 'half',
headers: DEFAULT_HEADERS,
method: 'POST',
// @ts-ignore
Expand Down

0 comments on commit 205d97b

Please sign in to comment.