Adding secrets doesn't work - wrong secret is used

Yes, I logged my secret out of frustration.

And the wrong secret is being passed via the props from the secrets variables.

It doesn’t seem to work.

Here is a video showing that adding the key doesn’t seem to work

Hi @Timfong888,

I’m sorry to hear you’re having trouble with your secrets. It sounds like there might be an issue with how the secrets are being passed or accessed in your Pipedream workflow. Here are a few steps you can take to troubleshoot and resolve the issue:

  1. Verify the Secret Value: Double-check the value of the secret in your Pipedream environment variables. Make sure it matches the expected value.

  2. Check Environment Variable Reference: Ensure that you’re referencing the environment variable correctly in your code. You should use process.env.VARIABLE_NAME to access the value of an environment variable.

  3. Update the Secret: If the secret value has changed, update it in the Pipedream environment variables and ensure your workflow is using the updated value.

  4. Review Code for Errors: Look through your code to ensure there are no syntax errors or logical issues that might be causing the wrong secret to be used.

  5. Logs and Debugging: Use Pipedream’s logging features to debug your workflow. You can log intermediate values to ensure the correct secret is being accessed.

  6. Re-deploy the Workflow: Sometimes, re-deploying the workflow can help apply any changes made to environment variables or code.

If you’ve tried these steps and are still experiencing issues, I recommend reaching out to Pipedream support for further assistance. You can visit Support - Pipedream for more support options.

If you have any more details or specific questions, feel free to share them, and I’ll do my best to assist you further.

I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double-check my answers and code! Learn how to build your own.

import axios from “axios”

export default defineComponent({
props: {
// — Core API Settings —
api_key: {
type: “string”,
label: “Zonos API Key”,
description: “Your Zonos API key (used in X-API-Key header)”,
secret: true,
},
model: {
type: “string”,
label: “Model”,
description: “Zyphra/Zonos model (e.g., zonos-v0.1-transformer)”,
default: “zonos-v0.1-transformer”,
},

// --- Text Input ---
transcript: {
  type: "string",
  label: "Text",
  description: "The text to convert to speech",
  optional: true,
},
// --- Speech Parameters (from cURL & Zonos examples) ---
speaking_rate: {
  type: "integer",
  label: "Speaking Rate",
  description: "Speech rate (e.g., 15)",
  default: 15,
},
language_iso_code: {
  type: "string",
  label: "Language ISO Code",
  description: "Language code (e.g., en-us, fr-fr)",
  optional: true,
  default: "en-us",
},

speaker_noised: {
  type: "boolean",
  label: "Speaker Noised",
  description: "Apply speaker noise?",
  optional: true,
  default: true,
},
voice_id: {
  type: "string",
  label: "Voice ID",
  description: "Specific voice ID (overrides default voice name if provided)",
  optional: true,
},
default_voice_name: {
  type: "string",
  label: "Default Voice Name",
  description: "Predefined voice name (e.g., american_female)",
  optional: true,
},

// --- Emotion Control ---
use_emotion: {
  type: "boolean",
  label: "Use Emotion Controls",
  description: "Enable custom emotion settings",
  default: false,
},
// *** Individual Emotion Props ***
emotion_happiness: { type: "string", label: "Emotion: Happiness", optional: true, default: "0.5", description: "Set happiness level (0-1)" },
emotion_neutral: { type: "string", label: "Emotion: Neutral", optional: true, default: "0.5", description: "Set neutral level (0-1)" },
emotion_sadness: { type: "string", label: "Emotion: Sadness", optional: true, default: "0.05", description: "Set sadness level (0-1)" },
emotion_disgust: { type: "string", label: "Emotion: Disgust", optional: true, default: "0.05", description: "Set disgust level (0-1)" },
emotion_fear: { type: "string", label: "Emotion: Fear", optional: true, default: "0.05", description: "Set fear level (0-1)" },
emotion_surprise: { type: "string", label: "Emotion: Surprise", optional: true, default: "0.05", description: "Set surprise level (0-1)" },
emotion_anger: { type: "string", label: "Emotion: Anger", optional: true, default: "0.05", description: "Set anger level (0-1)" },
emotion_other: { type: "string", label: "Emotion: Other", optional: true, default: "0.5", description: "Set 'other' emotion level (0-1)" },

// --- Debugging ---
debug_mode: {
  type: "boolean",
  label: "Debug Mode",
  description: "Print verbose debugging information",
  default: true,
}

},

async run({ steps, $ }) {
// Get the compaction data if available
const compactionData = steps.firebase_admin_sdk?.$return_value || {};

// Get text input
const text = this.transcript ||
            compactionData.compaction_text_human ||
            steps.trigger.event.body?.transcript || "";

// Add intro text if we have a title
let fullText = text;
if (compactionData.itemTitle) {
  fullText = `You are listening to a summary of ${compactionData.itemTitle}.---${text}`;
}

// --- Validation ---
if (!fullText || fullText.trim() === "") {
  throw new Error("No text provided for TTS conversion");
}
if (!this.api_key || this.api_key.trim() === "") {
  throw new Error("Zyphra API key is required");
}

// --- Payload Construction ---
let payload = {
  text: fullText,
  speaking_rate: this.speaking_rate,
  model: this.model,
};

// Conditionally add optional fields
if (this.language_iso_code) payload.language_iso_code = this.language_iso_code;
if (this.vqscore !== null && this.vqscore !== undefined) payload.vqscore = this.vqscore;
if (this.speaker_noised !== null && this.speaker_noised !== undefined) payload.speaker_noised = this.speaker_noised;
if (this.pitchStd !== null && this.pitchStd !== undefined) payload.pitchStd = this.pitchStd;

// Add voice selection
if (this.voice_id) payload.voice_id = this.voice_id;
else if (this.default_voice_name) payload.default_voice_name = this.default_voice_name;

// *** Conditionally add emotion object using individual props ***
if (this.use_emotion) {
  payload.emotion = {
    "happiness": this.emotion_happiness, // Use prop value
    "neutral": this.emotion_neutral,     // Use prop value
    "sadness": this.emotion_sadness,     // Use prop value
    "disgust": this.emotion_disgust,     // Use prop value
    "fear": this.emotion_fear,         // Use prop value
    "surprise": this.emotion_surprise,   // Use prop value
    "anger": this.emotion_anger,       // Use prop value
    "other": this.emotion_other        // Use prop value
  };
}

// --- Debug Logging ---
if (this.debug_mode) {
  console.log("=== ZYPHRA TTS REQUEST DEBUG (with individual emotion props) ===");
  console.log(`Target URL: http://api.zyphra.com/v1/audio/text-to-speech`);
  console.log(`Model: ${this.model}`);
  console.log(`Speaking Rate: ${this.speaking_rate}`);
  // ... (log other optional params similarly) ...
  console.log(`Use Emotion: ${this.use_emotion}`);
  if (this.use_emotion) {
     console.log(`Emotion Settings: Happiness=${this.emotion_happiness}, Neutral=${this.emotion_neutral}, Sadness=${this.emotion_sadness}, Disgust=${this.emotion_disgust}, Fear=${this.emotion_fear}, Surprise=${this.emotion_surprise}, Anger=${this.emotion_anger}, Other=${this.emotion_other}`);
     // Also log the constructed object for verification
     console.log(`Constructed Emotion Object: ${JSON.stringify(payload.emotion)}`);
  }
  console.log(`Text length: ${fullText.length} characters`);
  console.log("Payload being sent:");
  console.log(JSON.stringify(payload, null, 2));
  console.log("===========================================================");
}

try {
  // --- API Request ---
   const response = await axios({
    method: 'post',
    url: 'http://api.zyphra.com/v1/audio/text-to-speech',
    headers: {
      'X-API-Key': this.api_key,
      'Content-Type': 'application/json',
      'Accept': 'audio/webm, audio/*'
    },
    data: payload,
    responseType: 'arraybuffer',
    timeout: 60000,
    validateStatus: null
  });
  console.log(this.api_key);
  
  // --- Response Handling ---
  // (Response handling remains the same as the previous version)
  console.log(`Response status: ${response.status}`);
  console.log(`Content-Type: ${response.headers['content-type']}`);
  if (response.status !== 200) {
    const errorText = Buffer.from(response.data).toString('utf8');
    console.error(`Error response (${response.status}): ${errorText}`);
    let errorDetail = errorText;
    try {
      const errorJson = JSON.parse(errorText);
      errorDetail = errorJson.message || errorJson.detail || JSON.stringify(errorJson);
    } catch (e) { /* Ignore if not JSON */ }
    throw new Error(`Zyphra API error (${response.status}): ${errorDetail}`);
  }
  console.log(`Data length: ${response.data.byteLength} bytes`);
  const audioBuffer = Buffer.from(response.data);
  if (audioBuffer.length < 100) console.warn("Warning: Response is very small for audio data.");
  let fileExtension = 'webm';
  const contentType = response.headers['content-type'];
  if (contentType === 'audio/mpeg') fileExtension = 'mp3';
  else if (contentType === 'audio/wav') fileExtension = 'wav';
  const fileName = `${compactionData.video_id || compactionData.id || Date.now().toString()}.${fileExtension}`;

  // --- Return Result ---
  // (Return structure remains the same)
  return {
    audioBuffer,
    contentType: contentType || 'application/octet-stream',
    status: response.status,
    byteLength: audioBuffer.length,
    timestamp: Date.now(),
    model: this.model,
    compactionId: compactionData.id || null,
    videoId: compactionData.video_id || null,
    fileName: fileName,
    itemTitle: compactionData.itemTitle
  };

} catch (error) {
  // --- Error Handling ---
  // (Error handling remains the same as the previous version)
   console.error("Error during Zyphra TTS request execution:");
  if (error.response) {
    console.error(`Status Code: ${error.response.status}`);
    if(error.response.headers) console.error(`Headers: ${JSON.stringify(error.response.headers)}`);
    if (error.response.data) {
      try {
        const errorBody = (Buffer.isBuffer(error.response.data) || error.response.data instanceof ArrayBuffer)
                          ? Buffer.from(error.response.data).toString('utf8')
                          : JSON.stringify(error.response.data);
        console.error(`Response Body: ${errorBody}`);
        try {
           const errorJson = JSON.parse(errorBody);
           error.message = `Zyphra API Error: ${errorJson.detail || errorJson.message || errorBody}`;
        } catch(e) {
           error.message = `Zyphra API Error: ${errorBody}`;
        }
      } catch (e) { console.error("Could not fully process error response body."); }
    }
  } else if (error.request) {
    console.error("No response received from Zyphra API.");
    error.message = "No response received from Zyphra API (check network/timeout).";
  } else {
    console.error("Error setting up the request:", error.message);
  }
  throw error;
}

},
})

I can’t seem to change it.