fix(audio): misc

This commit is contained in:
Ibrahima G. Coulibaly 2025-07-08 17:43:44 +01:00
commit f3ed70258e
10 changed files with 55 additions and 52 deletions

57
.idea/workspace.xml generated
View file

@ -4,11 +4,15 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="chore: add array key"> <list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: groupBy tools autocomplete">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/Hero.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/Hero.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/components/input/ToolMultipleAudioInput.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/input/ToolMultipleAudioInput.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools-by-category/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools-by-category/index.tsx" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pages/tools/audio/extract-audio/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/audio/extract-audio/index.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/string.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/string.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/pages/tools/audio/extract-audio/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/audio/extract-audio/service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/audio/merge-audio/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/audio/merge-audio/index.tsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/audio/merge-audio/meta.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/audio/merge-audio/meta.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/tools/audio/merge-audio/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/tools/audio/merge-audio/service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/tools/index.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/tools/index.ts" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -22,7 +26,7 @@
<option name="PUSH_AUTO_UPDATE" value="true" /> <option name="PUSH_AUTO_UPDATE" value="true" />
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="fork/y1hao/dark" /> <entry key="$PROJECT_DIR$" value="fork/y1hao/grouping" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -209,7 +213,21 @@
"id": "PR_kwDOMJIfts6dwQJi", "id": "PR_kwDOMJIfts6dwQJi",
"number": 163 "number": 163
}, },
"lastSeen": 1751893861615 "lastSeen": 1751894349626
},
{
"id": {
"id": "PR_kwDOMJIfts6drHMN",
"number": 160
},
"lastSeen": 1751991164761
},
{
"id": {
"id": "PR_kwDOMJIfts6d1nEd",
"number": 165
},
"lastSeen": 1751992541880
} }
] ]
}]]></component> }]]></component>
@ -268,7 +286,7 @@
"Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run", "Vitest.replaceText function (regexp mode).should return the original text when passed an invalid regexp.executor": "Run",
"Vitest.replaceText function.executor": "Run", "Vitest.replaceText function.executor": "Run",
"Vitest.timeBetweenDates.executor": "Run", "Vitest.timeBetweenDates.executor": "Run",
"git-widget-placeholder": "#163 on fork/y1hao/grouping", "git-widget-placeholder": "#165 on fork/AshAnand34/audio-feature-addition",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true", "kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/pages/tools/json", "last_opened_file_path": "C:/Users/Ibrahima/IdeaProjects/omni-tools/src/pages/tools/json",
@ -509,15 +527,8 @@
<workItem from="1749047510481" duration="879000" /> <workItem from="1749047510481" duration="879000" />
<workItem from="1751846528195" duration="4358000" /> <workItem from="1751846528195" duration="4358000" />
<workItem from="1751852868038" duration="680000" /> <workItem from="1751852868038" duration="680000" />
<workItem from="1751893034799" duration="1192000" /> <workItem from="1751893034799" duration="1868000" />
</task> <workItem from="1751991143661" duration="1750000" />
<task id="LOCAL-00159" summary="refactor: sum">
<option name="closed" value="true" />
<created>1741544086061</created>
<option name="number" value="00159" />
<option name="presentableId" value="LOCAL-00159" />
<option name="project" value="LOCAL" />
<updated>1741544086061</updated>
</task> </task>
<task id="LOCAL-00160" summary="fix: tools by category scroll"> <task id="LOCAL-00160" summary="fix: tools by category scroll">
<option name="closed" value="true" /> <option name="closed" value="true" />
@ -903,7 +914,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1751893722720</updated> <updated>1751893722720</updated>
</task> </task>
<option name="localTasksCounter" value="208" /> <task id="LOCAL-00208" summary="feat: groupBy tools autocomplete">
<option name="closed" value="true" />
<created>1751894332017</created>
<option name="number" value="00208" />
<option name="presentableId" value="LOCAL-00208" />
<option name="project" value="LOCAL" />
<updated>1751894332017</updated>
</task>
<option name="localTasksCounter" value="209" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -950,7 +969,6 @@
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" /> <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_NEW_TODO" value="false" /> <option name="CHECK_NEW_TODO" value="false" />
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" /> <option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="refactor: compress pdf" />
<MESSAGE value="refactor: lib" /> <MESSAGE value="refactor: lib" />
<MESSAGE value="fix: path" /> <MESSAGE value="fix: path" />
<MESSAGE value="fix: vite worker format" /> <MESSAGE value="fix: vite worker format" />
@ -975,7 +993,8 @@
<MESSAGE value="fix: tsc" /> <MESSAGE value="fix: tsc" />
<MESSAGE value="chore: remove .codebuddy" /> <MESSAGE value="chore: remove .codebuddy" />
<MESSAGE value="chore: add array key" /> <MESSAGE value="chore: add array key" />
<option name="LAST_COMMIT_MESSAGE" value="chore: add array key" /> <MESSAGE value="feat: groupBy tools autocomplete" />
<option name="LAST_COMMIT_MESSAGE" value="feat: groupBy tools autocomplete" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<integration-enabled>false</integration-enabled> <integration-enabled>false</integration-enabled>

View file

@ -27,9 +27,7 @@ export default function ToolMultipleAudioInput({
title, title,
type type
}: MultiAudioInputComponentProps) { }: MultiAudioInputComponentProps) {
const theme = useTheme();
const fileInputRef = useRef<HTMLInputElement>(null); const fileInputRef = useRef<HTMLInputElement>(null);
const { showSnackBar } = useContext(CustomSnackBarContext);
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const files = event.target.files; const files = event.target.files;

View file

@ -181,7 +181,7 @@ export default function ChangeSpeed({
getGroups={getGroups} getGroups={getGroups}
setInput={setInput} setInput={setInput}
compute={compute} compute={compute}
toolInfo={{ title: `What is a ${title}?`, description: longDescription }} toolInfo={{ title: `What is ${title}?`, description: longDescription }}
/> />
); );
} }

View file

@ -1,12 +1,5 @@
import { import { Box } from '@mui/material';
Box, import React, { useState } from 'react';
FormControl,
InputLabel,
MenuItem,
Select,
SelectChangeEvent
} from '@mui/material';
import React, { useState, useEffect, useRef } from 'react';
import ToolContent from '@components/ToolContent'; import ToolContent from '@components/ToolContent';
import { ToolComponentProps } from '@tools/defineTool'; import { ToolComponentProps } from '@tools/defineTool';
import { extractAudioFromVideo } from './service'; import { extractAudioFromVideo } from './service';
@ -28,7 +21,6 @@ export default function ExtractAudio({
const [audioFile, setAudioFile] = useState<File | null>(null); const [audioFile, setAudioFile] = useState<File | null>(null);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
// Tool Options section for output format
const getGroups: GetGroupsType<InitialValuesType> = ({ const getGroups: GetGroupsType<InitialValuesType> = ({
values, values,
updateField updateField
@ -58,13 +50,12 @@ export default function ExtractAudio({
]; ];
}; };
// Compute function for ToolContent (no-op, extraction is handled by effect)
const compute = async (values: InitialValuesType, input: File | null) => { const compute = async (values: InitialValuesType, input: File | null) => {
if (!input) return; if (!input) return;
try { try {
setLoading(true); setLoading(true);
const audioFileObj = await extractAudioFromVideo(input, values); const audioFileObj = await extractAudioFromVideo(input, values);
await setAudioFile(audioFileObj); setAudioFile(audioFileObj);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} finally { } finally {
@ -84,15 +75,10 @@ export default function ExtractAudio({
<ToolFileResult <ToolFileResult
title={'Extracting Audio'} title={'Extracting Audio'}
value={null} value={null}
extension={''}
loading={true} loading={true}
/> />
) : ( ) : (
<ToolFileResult <ToolFileResult title={'Extracted Audio'} value={audioFile} />
title={'Extracted Audio'}
value={audioFile}
extension={initialValues.outputFormat}
/>
) )
} }
initialValues={initialValues} initialValues={initialValues}

View file

@ -20,7 +20,7 @@ export async function extractAudioFromVideo(
const configuredOutputAudioFormat = options.outputFormat; const configuredOutputAudioFormat = options.outputFormat;
const outputName = `output.${configuredOutputAudioFormat}`; const outputName = `output.${configuredOutputAudioFormat}`;
let args: string[] = ['-i', inputName, '-vn']; const args: string[] = ['-i', inputName, '-vn'];
if (configuredOutputAudioFormat === 'mp3') { if (configuredOutputAudioFormat === 'mp3') {
args.push( args.push(

View file

@ -106,7 +106,7 @@ export default function MergeAudio({
getGroups={getGroups} getGroups={getGroups}
setInput={setInput} setInput={setInput}
compute={compute} compute={compute}
toolInfo={{ title: `What is a ${title}?`, description: longDescription }} toolInfo={{ title: `What is ${title}?`, description: longDescription }}
/> />
); );
} }

View file

@ -4,7 +4,7 @@ import { lazy } from 'react';
export const tool = defineTool('audio', { export const tool = defineTool('audio', {
name: 'Merge Audio', name: 'Merge Audio',
path: 'merge-audio', path: 'merge-audio',
icon: 'mdi:music-note-multiple', icon: 'fluent:merge-20-regular',
description: description:
'Combine multiple audio files into a single audio file by concatenating them in sequence.', 'Combine multiple audio files into a single audio file by concatenating them in sequence.',
shortDescription: 'Merge multiple audio files into one (MP3, AAC, WAV).', shortDescription: 'Merge multiple audio files into one (MP3, AAC, WAV).',

View file

@ -36,7 +36,7 @@ export async function mergeAudioFiles(
await ffmpeg.writeFile(fileListName, fileListContent); await ffmpeg.writeFile(fileListName, fileListContent);
// Build FFmpeg arguments for merging // Build FFmpeg arguments for merging
let args: string[] = ['-f', 'concat', '-safe', '0', '-i', fileListName]; const args: string[] = ['-f', 'concat', '-safe', '0', '-i', fileListName];
// Add format-specific arguments // Add format-specific arguments
if (outputFormat === 'mp3') { if (outputFormat === 'mp3') {

View file

@ -122,7 +122,7 @@ export default function Trim({ title, longDescription }: ToolComponentProps) {
getGroups={getGroups} getGroups={getGroups}
setInput={setInput} setInput={setInput}
compute={compute} compute={compute}
toolInfo={{ title: `What is a ${title}?`, description: longDescription }} toolInfo={{ title: `What is ${title}?`, description: longDescription }}
/> />
); );
} }

View file

@ -1,7 +1,7 @@
import { stringTools } from '../pages/tools/string'; import { stringTools } from '../pages/tools/string';
import { imageTools } from '../pages/tools/image'; import { imageTools } from '../pages/tools/image';
import { DefinedTool, ToolCategory } from './defineTool'; import { DefinedTool, ToolCategory } from './defineTool';
import { capitalizeFirstLetter } from '../utils/string'; import { capitalizeFirstLetter } from '@utils/string';
import { numberTools } from '../pages/tools/number'; import { numberTools } from '../pages/tools/number';
import { videoTools } from '../pages/tools/video'; import { videoTools } from '../pages/tools/video';
import { audioTools } from 'pages/tools/audio'; import { audioTools } from 'pages/tools/audio';
@ -15,17 +15,17 @@ import { pdfTools } from '../pages/tools/pdf';
const toolCategoriesOrder: ToolCategory[] = [ const toolCategoriesOrder: ToolCategory[] = [
'image-generic', 'image-generic',
'string',
'json',
'pdf', 'pdf',
'string',
'video', 'video',
'time',
'audio',
'json',
'list', 'list',
'csv', 'csv',
'number', 'number',
'png', 'png',
'time', 'gif'
'gif',
'audio'
]; ];
export const tools: DefinedTool[] = [ export const tools: DefinedTool[] = [
...imageTools, ...imageTools,
@ -121,7 +121,7 @@ const categoriesConfig: {
}, },
{ {
type: 'audio', type: 'audio',
icon: 'rivet-icons:audio', icon: 'ic:twotone-audiotrack',
value: value:
'Tools for working with audio extract audio from video, adjusting audio speed, merging multiple audio files and much more.' 'Tools for working with audio extract audio from video, adjusting audio speed, merging multiple audio files and much more.'
} }