rampup 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +47 -21
  2. package/package.json +1 -2
package/index.js CHANGED
@@ -1004,39 +1004,65 @@ Be friendly, practical, and reference specific files when relevant. If asked abo
1004
1004
  async function playAudioChunks(chunks) {
1005
1005
  try {
1006
1006
  // Combine all chunks into one buffer
1007
- const audioBuffer = Buffer.concat(chunks);
1007
+ const pcmData = Buffer.concat(chunks);
1008
1008
 
1009
- // Save as raw PCM and convert to playable format
1010
- const rawPath = `/tmp/ramp-voice-${Date.now()}.raw`;
1009
+ // Create WAV file with proper headers (no external tools needed)
1010
+ const wavBuffer = createWavBuffer(pcmData, 24000, 1, 16);
1011
1011
  const wavPath = `/tmp/ramp-voice-${Date.now()}.wav`;
1012
1012
 
1013
- await fs.writeFile(rawPath, audioBuffer);
1013
+ await fs.writeFile(wavPath, wavBuffer);
1014
1014
 
1015
- // Convert raw PCM to WAV using sox or ffmpeg
1015
+ // Play audio
1016
1016
  if (process.platform === 'darwin') {
1017
- try {
1018
- // Try sox first
1019
- await execAsync(`sox -r 24000 -c 1 -b 16 -e signed-integer "${rawPath}" "${wavPath}" 2>/dev/null`);
1020
- await execAsync(`afplay "${wavPath}"`);
1021
- } catch {
1022
- // Try ffmpeg as fallback
1023
- try {
1024
- await execAsync(`ffmpeg -f s16le -ar 24000 -ac 1 -i "${rawPath}" "${wavPath}" -y 2>/dev/null`);
1025
- await execAsync(`afplay "${wavPath}"`);
1026
- } catch {
1027
- // Just try to play raw with afplay (may not work)
1028
- }
1029
- }
1017
+ await execAsync(`afplay "${wavPath}"`);
1018
+ } else if (process.platform === 'linux') {
1019
+ await execAsync(`aplay "${wavPath}" 2>/dev/null || paplay "${wavPath}" 2>/dev/null`).catch(() => {});
1030
1020
  }
1031
1021
 
1032
- // Clean up temp files
1033
- await fs.unlink(rawPath).catch(() => {});
1022
+ // Clean up
1034
1023
  await fs.unlink(wavPath).catch(() => {});
1035
1024
  } catch (err) {
1036
- // Silently fail audio playback
1025
+ // Log error for debugging but don't crash
1026
+ console.error(chalk.dim(`Audio playback error: ${err.message}`));
1037
1027
  }
1038
1028
  }
1039
1029
 
1030
+ // Create WAV buffer from raw PCM data
1031
+ function createWavBuffer(pcmData, sampleRate, numChannels, bitsPerSample) {
1032
+ const byteRate = sampleRate * numChannels * (bitsPerSample / 8);
1033
+ const blockAlign = numChannels * (bitsPerSample / 8);
1034
+ const dataSize = pcmData.length;
1035
+ const headerSize = 44;
1036
+ const fileSize = headerSize + dataSize;
1037
+
1038
+ const buffer = Buffer.alloc(fileSize);
1039
+ let offset = 0;
1040
+
1041
+ // RIFF header
1042
+ buffer.write('RIFF', offset); offset += 4;
1043
+ buffer.writeUInt32LE(fileSize - 8, offset); offset += 4;
1044
+ buffer.write('WAVE', offset); offset += 4;
1045
+
1046
+ // fmt subchunk
1047
+ buffer.write('fmt ', offset); offset += 4;
1048
+ buffer.writeUInt32LE(16, offset); offset += 4; // Subchunk1Size (16 for PCM)
1049
+ buffer.writeUInt16LE(1, offset); offset += 2; // AudioFormat (1 = PCM)
1050
+ buffer.writeUInt16LE(numChannels, offset); offset += 2;
1051
+ buffer.writeUInt32LE(sampleRate, offset); offset += 4;
1052
+ buffer.writeUInt32LE(byteRate, offset); offset += 4;
1053
+ buffer.writeUInt16LE(blockAlign, offset); offset += 2;
1054
+ buffer.writeUInt16LE(bitsPerSample, offset); offset += 2;
1055
+
1056
+ // data subchunk
1057
+ buffer.write('data', offset); offset += 4;
1058
+ buffer.writeUInt32LE(dataSize, offset); offset += 4;
1059
+
1060
+ // Copy PCM data
1061
+ pcmData.copy(buffer, offset);
1062
+
1063
+ return buffer;
1064
+ }
1065
+
1040
1066
  async function cleanup() {
1041
1067
  clearInterval(sessionTimer);
1042
1068
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rampup",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Ramp - Understand any codebase in hours. AI-powered developer onboarding CLI.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -46,7 +46,6 @@
46
46
  "open": "^9.1.0",
47
47
  "openai": "^4.0.0",
48
48
  "ora": "^5.4.1",
49
- "speaker": "^0.5.5",
50
49
  "ws": "^8.18.0"
51
50
  }
52
51
  }