-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yixin0909 zhang
authored and
yixin0909 zhang
committed
Jun 5, 2024
1 parent
7acdc4c
commit 1d9b897
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,51 @@ | ||
## Todolist | ||
|
||
### 修改代码,以实现以下功能并添加详细注释 | ||
[查阅文档](https://lmdeploy.readthedocs.io/zh-cn/latest/serving/api_server_vl.html) | ||
|
||
1.拆分代码为多个文件夹 | ||
- 拆分代码为多个文件夹,每个文件夹对应一个功能。 | ||
- 添加详细注释,以帮助理解代码。 | ||
|
||
**自动录制功能:** | ||
- 录制1小时的音频,并持续屏幕录制1小时。 | ||
- 默认录制音频5分钟,完成一次语音识别,请求一次分析结果, | ||
- 间隔时间可以配置 | ||
|
||
2. **结果显示:** | ||
- 自动显示分析后的结果。 | ||
|
||
3. **实时监控:** | ||
- 实时分析桌面内容,跟踪鼠标和键盘活动。 | ||
|
||
4. **摄像头分析:** | ||
- 分析连接的外部摄像头信息。 | ||
|
||
5. **中断与连续分析:** | ||
- 支持在分析过程中进行打断操作。 | ||
|
||
6. **快捷键替代:** | ||
- 使用快捷键代替Siri功能。 | ||
|
||
7. **会话管理:** | ||
- 允许在会话间开启或关闭应用对话状态。 | ||
|
||
8. **内存优化:** | ||
- 使用缓冲区处理,减少磁盘读写。 | ||
|
||
9. **用户界面配置:** | ||
- 配置助手音频参数(如速度)及播放选项。 | ||
- 设置窗口始终位于顶层(启用/禁用粘性位置)。 | ||
- 屏幕截图设置自定义(如选择区域或全屏)。 | ||
|
||
10. **麦克风修复:** | ||
- 解决麦克风在.app中无法正常工作的bug,感谢@Claar修复。 | ||
|
||
11. **文本输入支持:** | ||
- 添加基于文本的输入替代语音识别。 | ||
|
||
12. **OpenAI 接口替代方案:** | ||
- 由于官方接口可能受限,可以考虑使用第三方服务获取OpenAI密钥,如: | ||
- [https://one.gptnb.me/](https://one.gptnb.me/) | ||
- [https://www.gptapi.us/](https://www.gptapi.us/) | ||
- [https://aihubmix.com/](https://aihubmix.com/) |
This file contains 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,25 @@ | ||
// Manage API key storage/access | ||
ipcMain.on("submit-api-key", (event, apiKey) => { | ||
store.set("userApiKey", apiKey); // Directly saving the API key using electron-store | ||
}); | ||
|
||
// Function to mask the API key except for the last 4 characters | ||
function maskApiKey(apiKey) { | ||
if (apiKey.length <= 4) { | ||
return apiKey; // If the key is too short, just return it | ||
} | ||
return "*".repeat(apiKey.length - 4) + apiKey.slice(-4); | ||
} | ||
|
||
// Handle request for API key | ||
ipcMain.on("request-api-key", (event) => { | ||
const apiKey = store.get("userApiKey", ""); // Get the API key | ||
const maskedApiKey = maskApiKey(apiKey); // Get the masked version | ||
event.reply("send-api-key", maskedApiKey); // Send the masked key | ||
}); | ||
|
||
// fetch the key to send to backend logic | ||
ipcMain.handle("get-api-key", (event) => { | ||
return store.get("userApiKey", ""); | ||
}); | ||
|
This file contains 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,45 @@ | ||
|
||
ipcMain.on("video-buffer", (event, buffer) => { | ||
// const outputPath = path.resolve(__dirname, 'recording.webm'); // 设置输出路径 | ||
fs.writeFile(videoFilePath, buffer, (err) => { | ||
// 将视频数据写入文件 | ||
if (err) { | ||
console.error("Error saving video file:", err); | ||
} else { | ||
console.log("Video saved to:", videoFilePath); | ||
} | ||
}); | ||
}); | ||
|
||
ipcMain.on("save-video-frame", (event, buffer) => { | ||
const outputFramePath = path.join(tempFilesDir, `frame_${Date.now()}.png`); // 自定义保存路径和文件名,这里保存为 PNG 图片文件,你可以根据需要修改为其他格式或处理方式 | ||
fs.writeFile(outputFramePath, buffer, (err) => { | ||
// 将视频数据写入文件 | ||
if (err) { | ||
console.error("Error saving video file:", err); | ||
} else { | ||
// 将帧数据写入文件 | ||
console.log(`saved to ${outputFramePath}`); // 输出保存路径和帧编号,便于调试和跟踪录制状态和进度 | ||
} | ||
}); | ||
}); | ||
ipcMain.on("save-video", async (event, blob) => { | ||
try { | ||
// 将 Blob 对象转换为 ArrayBuffer | ||
const arrayBuffer = await blob.arrayBuffer(); | ||
// 将 ArrayBuffer 转换为 Buffer | ||
const buffer = Buffer.from(arrayBuffer); | ||
// 定义输出路径,文件名使用当前时间戳来保证唯一性 | ||
const outputPath = path.join(tempFilesDir, `video_${Date.now()}.webm`); | ||
// 使用 fs.writeFileSync 同步写入文件,也可以使用 fs.writeFile 异步写入 | ||
fs.writeFileSync(outputPath, buffer); | ||
// 可选:回复渲染进程文件已保存的消息和路径 | ||
event.reply("video-saved", outputPath); | ||
console.log(`Video saved to: ${outputPath}`); | ||
} catch (error) { | ||
console.error("Error saving video:", error); | ||
// 可选:回复渲染进程保存视频时发生的错误 | ||
event.reply("video-save-error", error); | ||
} | ||
}); | ||
|