-
Notifications
You must be signed in to change notification settings - Fork 17
feat(ui): Whisper dropdown TINY/BASE buttons + clickable topbar label… #220
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
52dc2f6
feat(ui): Whisper dropdown TINY/BASE buttons + clickable topbar label…
Constantine-S-AN 9cd1ce4
Whisper: add gear popover to pick model
Constantine-S-AN 3f0ce48
ui gear and new windows done
Constantine-S-AN ecef780
ui gear and new windows done
Constantine-S-AN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // src/components/icons/WhisperIcon.tsx | ||
| import * as React from 'react'; | ||
| import { useMediaQuery, useTheme } from '@mui/material'; | ||
|
|
||
|
|
||
| import GraphicEqIcon from '@mui/icons-material/GraphicEq'; | ||
| // import ClosedCaptionIcon from '@mui/icons-material/ClosedCaption'; | ||
| // import SettingsVoiceIcon from '@mui/icons-material/SettingsVoice'; | ||
|
|
||
| export default function WhisperIcon() { | ||
| const theme = useTheme(); | ||
| const isMobile = useMediaQuery(theme.breakpoints.down('sm')); | ||
| const fontSize: 'small' | 'medium' = isMobile ? 'small' : 'medium'; | ||
|
|
||
| return <GraphicEqIcon fontSize={fontSize} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,80 @@ | ||
| import React, { useState } from 'react'; | ||
| import { List, ListItem, Button } from '../../../../muiImports' | ||
| import React, { useState } from 'react'; | ||
| import { useDispatch, useSelector } from 'react-redux'; | ||
|
|
||
| // Pull UI pieces from the same aggregator used elsewhere | ||
| import { | ||
| IconButton, | ||
| Tooltip, | ||
| Menu, | ||
| MenuItem, | ||
| SettingsIcon, // this should be re-exported by your muiImports like other icons | ||
| } from '../../../../muiImports'; | ||
|
|
||
| export default function WhisperDropdown(props) { | ||
| import { selectSelectedModel } from | ||
| '../../../../react-redux&middleware/redux/reducers/modelSelectionReducers'; | ||
|
|
||
| // const [isTrue, setIsTrue] = useState<boolean>(false); | ||
| // const [isClearCache, setIsClearCache] = useState<boolean>(false); | ||
| const [isDownloadTiny, setIsDownloadTiny] = useState<boolean>(false); | ||
| const [isDownloadBase, setIsDownloadBase] = useState<boolean>(false); | ||
| // const [progress, setProgress] = useState(null); | ||
| // const [showModal, setShowModal] = useState(false); | ||
| type Props = { onPicked?: () => void }; | ||
|
|
||
| type ModelKey = 'tiny' | 'base'; | ||
|
|
||
| const handleTinyDownload = () => { | ||
| console.log("clicked download tiny") | ||
| setIsDownloadTiny(prevIsDownloadTiny => !prevIsDownloadTiny); | ||
| sessionStorage.setItem('isDownloadTiny', (!isDownloadTiny).toString()); | ||
| }; | ||
| // Helper to normalize current selection into 'tiny' | 'base' | undefined | ||
| function normalizeSelected(selected: unknown): ModelKey | undefined { | ||
| if (typeof selected === 'string') { | ||
| return selected === 'tiny' || selected === 'base' ? selected : undefined; | ||
| } | ||
| if (selected && typeof selected === 'object' && 'key' in (selected as any)) { | ||
| const k = (selected as any).key; | ||
| return k === 'tiny' || k === 'base' ? k : undefined; | ||
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| const handleBaseDownload = () => { | ||
| console.log("clicked download tiny") | ||
| setIsDownloadBase(prevIsDownloadBase => !prevIsDownloadBase); | ||
| sessionStorage.setItem('isDownloadBase', (!isDownloadBase).toString()); | ||
| export default function WhisperDropdown({ onPicked }: Props) { | ||
| const dispatch = useDispatch(); | ||
| const selected = useSelector(selectSelectedModel); | ||
| const selectedKey = normalizeSelected(selected); | ||
|
|
||
| const intervalId = setInterval(() => { | ||
| let p = sessionStorage.getItem('whisper_progress'); | ||
| if (p === '100') { | ||
| alert("Base model downloaded! trigger the mike by stopping and starting again"); | ||
| clearInterval(intervalId); // Stop checking once it's 100% | ||
| } | ||
| }, 2000); // Check every 2000 milliseconds, or 2 seconds | ||
| }; | ||
| const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null); | ||
| const open = Boolean(anchorEl); | ||
|
|
||
| // --------------- Using a modal to show the progress | ||
| const handleOpen = (e: React.MouseEvent<HTMLElement>) => setAnchorEl(e.currentTarget); | ||
| const handleClose = () => setAnchorEl(null); | ||
|
|
||
| // const handleBaseDownload = () => { | ||
| // console.log("clicked download base"); | ||
| // setIsDownloadBase(prevIsDownloadBase => !prevIsDownloadBase); | ||
| // sessionStorage.setItem('isDownloadBase', (!isDownloadBase).toString()); | ||
|
|
||
| // // Initially show the modal | ||
| // setShowModal(true); | ||
|
|
||
| // const intervalId = setInterval(() => { | ||
| // let p = sessionStorage.getItem('whisper_progress'); | ||
| // setProgress(p); // Update the progress | ||
| // if (p === '100%') { | ||
| // clearInterval(intervalId); // Stop checking once it's 100% | ||
| // } | ||
| // }, 2000); | ||
| // }; | ||
|
|
||
| // // Close the modal when progress reaches 100% | ||
| // useEffect(() => { | ||
| // if (progress === '100%') { | ||
| // setShowModal(false); | ||
| // } | ||
| // }, [progress]); | ||
| const pick = (which: ModelKey) => { | ||
| // Keep the existing flags your loader is watching | ||
| sessionStorage.setItem('isDownloadTiny', String(which === 'tiny')); | ||
| sessionStorage.setItem('isDownloadBase', String(which === 'base')); | ||
|
|
||
|
|
||
| // Update Redux – if you have a real action creator, use it here | ||
| dispatch({ type: 'SET_SELECTED_MODEL', payload: which as any }); | ||
|
|
||
| // const handleClickClearCache = () => { | ||
| // console.log("clicked cache") | ||
| // setIsClearCache(prevIsClearCache => !prevIsClearCache); | ||
| // sessionStorage.setItem('isClearCache', (!isClearCache).toString()); | ||
| // }; | ||
| handleClose(); | ||
| onPicked?.(); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| {/* Right-aligned gear like other providers */} | ||
| <Tooltip title="Whisper settings"> | ||
| <IconButton onClick={handleOpen} size="large"> | ||
| <SettingsIcon /> | ||
| </IconButton> | ||
| </Tooltip> | ||
|
|
||
| return ( | ||
| <> | ||
| <div> | ||
| <List component="div" disablePadding> | ||
| <ListItem sx={{ pl: 4 }} style={{ width: '100%' }}> | ||
| <Button onClick={()=>{handleTinyDownload()}} variant="contained" color="inherit" style={{ width: '100%' }}>tiny (75 MB)</Button> | ||
| </ListItem> | ||
| <ListItem sx={{ pl: 4 }} style={{ width: '100%' }}> | ||
| <Button onClick={()=>{handleBaseDownload()}} variant="contained" color="inherit" style={{ width: '100%' }}>base (145 MB)</Button> | ||
| </ListItem> | ||
| {/* TODO: add clear cache to delete the database with whisper.cpp models */} | ||
| {/* <ListItem sx={{ pl: 4 }} style={{ width: '100%' }}> | ||
| <Button onClick={()=>{handleClickClearCache()}} variant="contained" color="inherit" style={{ width: '100%' }}>Clear cache</Button> | ||
| </ListItem> */} | ||
| </List> | ||
| </div> | ||
| </> | ||
| ) | ||
| } | ||
| <Menu | ||
| anchorEl={anchorEl} | ||
| open={open} | ||
| onClose={handleClose} | ||
| anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }} | ||
| transformOrigin={{ horizontal: 'right', vertical: 'top' }} | ||
| > | ||
| <MenuItem selected={selectedKey === 'tiny'} onClick={() => pick('tiny')}> | ||
| TINY (75 MB) | ||
| </MenuItem> | ||
| <MenuItem selected={selectedKey === 'base'} onClick={() => pick('base')}> | ||
| BASE (145 MB) | ||
| </MenuItem> | ||
| </Menu> | ||
| </> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.