Skip to content

Commit 0b17cf7

Browse files
authored
12 feature enable the user to customize file names (#13)
* Base impl to enable prefix set as an option * Fix for root vault folder showing as empty when selected * Enabling the filename prefix to be set * Save filename prefix things on button click so there can be validation * remove console log * Adds recordingFilenamePrefix to settings * Fixes file exists logic in rename * uses filename prefix from settings * Shows saved notifciation on directory changes * Adds note that this will be improved * Bump version number * Fix formatting that got weird for some reason
1 parent b938846 commit 0b17cf7

File tree

7 files changed

+264
-94
lines changed

7 files changed

+264
-94
lines changed

manifest.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"id": "scribe",
3-
"name": "Scribe",
4-
"version": "1.0.6",
5-
"minAppVersion": "0.15.0",
6-
"description": "Record voice notes, Fill in lost thoughts, Transcribe the audio, Summarize & Visualize the text - All in one clip",
7-
"author": "Mike Alicea",
8-
"authorUrl": "https://github.com/Mikodin/",
9-
"fundingUrl": "https://buymeacoffee.com/mikealicea",
10-
"isDesktopOnly": false
2+
"id": "scribe",
3+
"name": "Scribe",
4+
"version": "1.0.7",
5+
"minAppVersion": "0.15.0",
6+
"description": "Record voice notes, Fill in lost thoughts, Transcribe the audio, Summarize & Visualize the text - All in one clip",
7+
"author": "Mike Alicea",
8+
"authorUrl": "https://github.com/Mikodin/",
9+
"fundingUrl": "https://buymeacoffee.com/mikealicea",
10+
"isDesktopOnly": false
1111
}

package.json

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
{
2-
"name": "obsidian-scribe-plugin",
3-
"version": "1.0.6",
4-
"description": "An Obsidian plugin for recording voice notes, transcribing the audio, and summarizing the text - All in one",
5-
"main": "build/main.js",
6-
"scripts": {
7-
"dev": "node esbuild.config.mjs",
8-
"build:prod": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
9-
"version": "node version-bump.mjs && git add manifest.json versions.json"
10-
},
11-
"keywords": [],
12-
"author": "Mike Alicea",
13-
"license": "MIT",
14-
"devDependencies": {
15-
"@biomejs/biome": "1.9.4",
16-
"@types/node": "^16.11.6",
17-
"@types/react": "^18.3.12",
18-
"@types/react-dom": "^18.3.1",
19-
"builtin-modules": "3.3.0",
20-
"dotenv": "^16.4.5",
21-
"esbuild": "0.17.3",
22-
"obsidian": "latest",
23-
"tslib": "2.4.0",
24-
"typescript": "4.7.4"
25-
},
26-
"dependencies": {
27-
"@langchain/core": "^0.3.14",
28-
"@langchain/openai": "^0.3.11",
29-
"assemblyai": "^4.8.0",
30-
"langchain": "^0.3.3",
31-
"openai": "^4.68.3",
32-
"react": "^18.3.1",
33-
"react-dom": "^18.3.1",
34-
"zod": "^3.23.8"
35-
}
2+
"name": "obsidian-scribe-plugin",
3+
"version": "1.0.7",
4+
"description": "An Obsidian plugin for recording voice notes, transcribing the audio, and summarizing the text - All in one",
5+
"main": "build/main.js",
6+
"scripts": {
7+
"dev": "node esbuild.config.mjs",
8+
"build:prod": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
9+
"version": "node version-bump.mjs && git add manifest.json versions.json"
10+
},
11+
"keywords": [],
12+
"author": "Mike Alicea",
13+
"license": "MIT",
14+
"devDependencies": {
15+
"@biomejs/biome": "1.9.4",
16+
"@types/node": "^16.11.6",
17+
"@types/react": "^18.3.12",
18+
"@types/react-dom": "^18.3.1",
19+
"builtin-modules": "3.3.0",
20+
"dotenv": "^16.4.5",
21+
"esbuild": "0.17.3",
22+
"obsidian": "latest",
23+
"tslib": "2.4.0",
24+
"typescript": "4.7.4"
25+
},
26+
"dependencies": {
27+
"@langchain/core": "^0.3.14",
28+
"@langchain/openai": "^0.3.11",
29+
"assemblyai": "^4.8.0",
30+
"langchain": "^0.3.3",
31+
"openai": "^4.68.3",
32+
"react": "^18.3.1",
33+
"react-dom": "^18.3.1",
34+
"zod": "^3.23.8"
35+
}
3636
}

src/index.ts

+17-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
addAudioSourceToFrontmatter,
1515
addSummaryToNote,
1616
addTranscriptToNote,
17-
createBaseFileName,
1817
createNewNote,
1918
renameFile,
2019
saveAudioRecording,
@@ -31,6 +30,7 @@ import {
3130
} from './util/mimeType';
3231
import { extractMermaidChart } from './util/textUtil';
3332
import { transcribeAudioWithAssemblyAi } from './util/assemblyAiUtil';
33+
import { formatFilenamePrefix } from './util/filenameUtils';
3434

3535
export interface ScribeState {
3636
isOpen: boolean;
@@ -128,13 +128,15 @@ export default class ScribePlugin extends Plugin {
128128

129129
async scribe(scribeOptions: ScribeOptions = {}) {
130130
try {
131-
const baseFileName = createBaseFileName();
131+
const baseFileName = formatFilenamePrefix(
132+
this.settings.recordingFilenamePrefix,
133+
this.settings.dateFilenameFormat,
134+
);
132135

133136
const { recordingBuffer, recordingFile } =
134137
await this.handleStopAndSaveRecording(baseFileName);
135138

136139
await this.handleScribeFile({
137-
baseNoteAndAudioFileName: baseFileName,
138140
audioRecordingFile: recordingFile,
139141
audioRecordingBuffer: recordingBuffer,
140142
scribeOptions: scribeOptions,
@@ -157,12 +159,10 @@ export default class ScribePlugin extends Plugin {
157159
new Notice('Scribe: ⚠️ This file type is not supported.');
158160
return;
159161
}
160-
const baseFileName = createBaseFileName();
161162

162163
const audioFileBuffer = await this.app.vault.readBinary(audioFile);
163164

164165
await this.handleScribeFile({
165-
baseNoteAndAudioFileName: baseFileName,
166166
audioRecordingFile: audioFile,
167167
audioRecordingBuffer: audioFileBuffer,
168168
});
@@ -227,18 +227,19 @@ export default class ScribePlugin extends Plugin {
227227
}
228228

229229
async handleScribeFile({
230-
baseNoteAndAudioFileName,
231230
audioRecordingFile,
232231
audioRecordingBuffer,
233232
scribeOptions = {},
234233
}: {
235-
baseNoteAndAudioFileName: string;
236234
audioRecordingFile: TFile;
237235
audioRecordingBuffer: ArrayBuffer;
238236
scribeOptions?: ScribeOptions;
239237
}) {
240238
const { isAppendToActiveFile, isOnlyTranscribeActive } = scribeOptions;
241-
const scribeNoteFilename = `scribe-${baseNoteAndAudioFileName}`;
239+
const scribeNoteFilename = `${formatFilenamePrefix(
240+
this.settings.noteFilenamePrefix,
241+
this.settings.dateFilenameFormat,
242+
)}`;
242243

243244
let note = isAppendToActiveFile
244245
? this.app.workspace.getActiveFile()
@@ -271,7 +272,11 @@ export default class ScribePlugin extends Plugin {
271272

272273
const shouldRenameNote = !isAppendToActiveFile;
273274
if (shouldRenameNote) {
274-
const llmFileName = `scribe-${moment().format('YYYY-MM-DD')}-${normalizePath(llmSummary.title)}`;
275+
const llmFileName = `${formatFilenamePrefix(
276+
this.settings.noteFilenamePrefix,
277+
this.settings.dateFilenameFormat,
278+
)}${normalizePath(llmSummary.title)}`;
279+
275280
await renameFile(this, note, llmFileName);
276281
}
277282
}
@@ -298,7 +303,9 @@ export default class ScribePlugin extends Plugin {
298303
return transcript;
299304
} catch (error) {
300305
new Notice(
301-
`Scribe: 🎧 🛑 Something went wrong trying to Transcribe w/ ${this.settings.transcriptPlatform}
306+
`Scribe: 🎧 🛑 Something went wrong trying to Transcribe w/ ${
307+
this.settings.transcriptPlatform
308+
}
302309
${error.toString()}`,
303310
);
304311

0 commit comments

Comments
 (0)