Skip to content

OpenAI Speech to Text / Create Transcription #16544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import openai from "../../openai.app.mjs";
import FormData from "form-data";
import fs from "fs";

export default {
key: "openai-create-transcription",
name: "Create Transcription",
description: "Transcribes audio into the input language. [See the documentation](https://platform.openai.com/docs/api-reference/audio/createTranscription)",
version: "0.2.0",
type: "action",
props: {
openai,
file: {
propDefinition: [
openai,
"file",
],
},
model: {
type: "string",
label: "Model",
description: "ID of the model to use",
options: [
"gpt-4o-transcribe",
"gpt-4o-mini-transcribe",
"whisper-1",
],
},
include: {
type: "string[]",
label: "Include",
description: "Additional information to include in the transcription response. `logprobs` will return the log probabilities of the tokens in the response to understand the model's confidence in the transcription. `logprobs` only works with response_format set to `json` and only with the models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`.",
optional: true,
},
language: {
type: "string",
label: "Language",
description: "The language of the input audio. Supplying the input language in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. en) format will improve accuracy and latency.",
default: "en",
optional: true,
},
prompt: {
type: "string",
label: "Prompt",
description: "An optional text to guide the model's style or continue a previous audio segment. The [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting) should match the audio language.",
optional: true,
},
response_format: {
type: "string",
label: "Response Format",
description: "The format of the output. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`, the only supported format is `json`.",
options: [
"json",
"text",
"srt",
"verbose_json",
"vtt",
],
optional: true,
},
temperature: {
type: "string",
label: "Temperature",
description: "The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.",
optional: true,
},
timestamp_granularities: {
type: "string[]",
label: "Timestamp Granularities",
description: "The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.",
optional: true,
},
},
methods: {
createTranscription(opts = {}) {
return this.openai._makeRequest({
method: "POST",
path: "/audio/transcriptions",
...opts,
});
},
},
async run({ $ }) {
const {
/* eslint-disable no-unused-vars */
openai,
file,
createTranscription,
...fields
} = this;

const data = new FormData();
const content = fs.createReadStream(file.includes("tmp/")
? file
: `/tmp/${file}`);

data.append("file", content);

for (const [
key,
value,
] of Object.entries(fields)) {
const v = Array.isArray(value)
? value.join(",")
: value;
data.append(key, v);
}

const response = await createTranscription({
$,
data,
headers: data.getHeaders(),
});

$.export("$summary", "Successfully converted speech to text");
return response;
},
};
2 changes: 1 addition & 1 deletion components/openai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/openai",
"version": "0.9.4",
"version": "0.10.0",
"description": "Pipedream OpenAI Components",
"main": "openai.app.mjs",
"keywords": [
Expand Down
12 changes: 4 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading