mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-11 12:05:33 +08:00
readback ptt geht
This commit is contained in:
@@ -7,6 +7,7 @@ import { tmpdir } from "node:os";
|
|||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
import { execFile } from "node:child_process";
|
import { execFile } from "node:child_process";
|
||||||
import { openai, LLM_MODEL, normalizeATC } from "../../utils/openai";
|
import { openai, LLM_MODEL, normalizeATC } from "../../utils/openai";
|
||||||
|
import { createReadStream } from "node:fs"; // ← Diesen Import hinzufügen!
|
||||||
|
|
||||||
interface PTTRequest {
|
interface PTTRequest {
|
||||||
audio: string; // Base64 encoded audio
|
audio: string; // Base64 encoded audio
|
||||||
@@ -232,7 +233,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
|
|
||||||
// 3. OpenAI Whisper für Transkription
|
// 3. OpenAI Whisper für Transkription
|
||||||
const transcription = await openai.audio.transcriptions.create({
|
const transcription = await openai.audio.transcriptions.create({
|
||||||
file: await readFile(audioFileForWhisper),
|
file: createReadStream(audioFileForWhisper), // ReadStream
|
||||||
model: "whisper-1",
|
model: "whisper-1",
|
||||||
language: "en", // ATC ist standardmäßig auf Englisch
|
language: "en", // ATC ist standardmäßig auf Englisch
|
||||||
prompt: "This is ATC radio communication with aviation phraseology including callsigns, runway numbers, and standard procedures.",
|
prompt: "This is ATC radio communication with aviation phraseology including callsigns, runway numbers, and standard procedures.",
|
||||||
@@ -273,7 +274,6 @@ export default defineEventHandler(async (event) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Cleanup bei Fehler
|
// Cleanup bei Fehler
|
||||||
await rm(tmpAudioInput).catch(() => {});
|
await rm(tmpAudioInput).catch(() => {});
|
||||||
await rm(tmpAudioWav).catch(() => {});
|
|
||||||
|
|
||||||
if (error.statusCode) {
|
if (error.statusCode) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Reference in New Issue
Block a user