本地化搭建fast-whisper+ChatGLM2-6B出来会谈记录

ffmpeg -i  20230703am.mp3 -f segment -segment_time 1755 -write_xing 0 -c copy  20230703am/out%03d.mp3

首先用以上命令将长音频切分为每30分钟一段,因为fast-whisper有这样的限制,实际切分的时候不要设置为1800秒,因为会多一点点,无法通过,可以设置到1799秒。

fast-whisper用官方的docker方案直接跑,试了一下medium模型和largv2都还行,默认就用medium了。

转录出来的文本用ChatGLM2-6B来处理,比如用这样的提示词:“请整理以下录音识别的文字,去掉其中的语气词等多余的部分,将语句调整通顺,修复可能因为语音识别产生的错误。”

ChatGLM2-6B直接按官方库的方法部署即可,通过webui访问。

如果希望自己对照查看文本,可以用VLC打开audio的visualizations效果即可显示字幕,也可以用subtitle编辑。

用VLC播放mp3的时候,默认看不到字幕,需要手动打开音频可视化。

图形默认是正方的,看着有点别扭,那么再调整一下视频比例。

更详细的情况欢迎联系我交流。

自动压缩当前文件夹及所有子文件夹的图片代码

#!/usr/bin/python
# -*- coding: UTF-8 -*-

'''
Author: be_loving@163.com 
Date: 2023-06-26 20:13:21
LastEditors: be_loving@163.com 
LastEditTime: 2023-06-26 21:28:50
Description: 

Copyright (c) 2023 Jiulu LTD, All Rights Reserved. 
'''
# pip install Pillow
import os
from PIL import Image
Image.MAX_IMAGE_PIXELS = None

for root, dirs, files in os.walk(".", topdown=False):
    for name in files:

        if name.endswith(".jpg") or name.endswith(".jpeg") or name.endswith(".png") or name.endswith(".tif"):
            img_path = os.path.join(root, name)
            print(img_path)
            if img_path.count('_144') > 1:
                os.remove(img_path)
            elif img_path.count('_144') == 0:
                new_img_path = os.path.join(
                    root, f"{name}_144.jpg")
                print(new_img_path)
                if not os.path.isfile(new_img_path):
                    try:
                        with Image.open(img_path) as img:
                            img.save(new_img_path, dpi=(144, 144))
                    except(OSError, NameError):
                        print('OSError,Path:', img_path)

    # for name in dirs:
    #     print(os.path.join(root, name))

具体压缩参数及文件命名方式请自己参照pillow的文档修改。

脚本运行时可执行

python ./resize.py

但需要当前的python环境支持pillow,可以直接安装,也可以用conda来定制环境,比如在conda create命令下安装pillow之后用conda activate pillow激活该环境。

萤石云录像机CS-N1-208硬盘报警消除

萤石云录像机CS-N1-208突然间开始连续发出滴滴滴三声蜂鸣,打客服电话问,说可以把报警声关掉。

但检查后发现不只是有报警音的问题,关键是硬盘不转,以为硬盘坏了,换了一个硬盘,依然不转,进入系统,识别不到硬盘。以为主板坏了,打算换一个主板,结果在淘宝上了咨询了一下老板,直接回复是电源的问题,原来的使用的电源是0.7A(12V),远远不够,建议升到2A以上。

于是用一个笔记本电脑的电源(19V)加上一个可调降压模块(12V),开机成功,硬盘也恢复了。

我不理解的是之前它是怎么正常工作的。

顺带备注一下:这个录像机恢复初始密码后,密码是盒子标签上的验证码,区分大小写。网上查到的文档都是说12345,不对。

在ox11以上版本的mac上安装DocuPrint C1110B

DocuPrint C1110B大概是针对中国大陆市场投放的一个打印机型号,目前官方网站已经停止了对这个型号的售后支持,包括驱动下载,即使各种搜索,也只能在非官方网站上找到兼容到ox10的驱动安装包。

一直找到很晚,因为眼睛看花了,误把DocuPrint C1100看成了DocuPrint C1110,所以将错就错在下面这个网址下载了DocuPrint C1100的驱动。

https://www.fujifilm.com/fb/download/eng/docuprint

打开上面的网址,选择相应的型号,点击该型号链接,打开新的页面,切换到mac的tab上,选择想要的系统版本项,打开的是一个日文的页面,没关系,用一下翻译插件,点击同意并下载,在mac上打开这个驱动并安装。

在usb上连接上打印机,并开机,添加打印机,这个时候如果还是没有显示打印机型号,显示为普通的PLC打印机,则选择其他,然后定位到系统盘的“资源库-Printers-PPDS-Contents-Resources-FX DocuPrint C1100”即可添加成功。

第二天再仔细看才发现具体型号是DocuPrint C1100,到官网查看了一下产品照片,其实和DocuPrint C1110一样,那么用的芯片实际上也是一样的了。在武汉的时候修打印机的师傅告诉我,打印机虽然那么多型号,但实际上芯片规格并不多,很多很神奇的联想方正打印机,直接到日本打印机官网去下载某型号的驱动就可以用,因为都是贴牌或套壳的。

北京真露营时间区间

所谓真露营,就是真的在户外的露营地过夜,这两年很多说露营的实际上多半是野餐级别的。

那么对于多数人来说目前挑战高级别露营是有难度的,装备很贵,经验太少。那么,就在真露营里面,挑一个相对舒适的时间。

北京露营适宜区间(全年温度曲线图)

从图上来看,我们把轻度露营再分为两个级别,一个是夜间最低温度10度以上,一个是夜间最低温度15度以上。10度以上是从4月中旬到9月底,这5个多月的时间段,15度以上是从5月初到8月底这4个月的时间端。

关于露营期间玩什么,除了吃喝,还可以看电影、唱歌、打扑克。也可以看看书,听听音乐,看看星星。

vite项目引入vue3-carousel-3d时添加declare module ‘vue3-carousel-3d’

vite/vue3中引入vue3-carousel-3d组件时会报错,vue3-carousel-3d是基于vue-carousel-3d改造的,但没有提供types文件。为了解决这个问题,需要在项目中自行添加一个文件,比如命名为vendor.d.ts(可以放在types文件夹,并在tsconfig.json的types数组中添加./types/vendor.d.ts),内容如下:

declare module 'vue3-carousel-3d';

这样,就能正常使用了。

博锐剃须刀PS108拆解

最近新买的博锐剃须刀PS108充电不太足,想打开看看什么原因。但是拆解的时候遇到了麻烦,这个新款结构设计很是奇特,打开了刀头,发现点持仓应该还是从底部充电口的位置才能拆开。

博锐PS108刀头
博锐PS108刀头拆解
博锐PS108充电头

从底部的外观来看,没有螺丝,应该是用的卡子接口或者螺口,如果是螺口的话,能着力的点就是充电的usb口,拿螺丝刀试着拧了一下,发现不对劲。

于是,拿美工刀直接从缝里开撬,撬起一个缝就用平头螺丝刀插进去,使劲,就把底部的这个卡片撬下来了。图片上能看到,结构其实不复杂,底片上有个固定充电口的结构,里面电池仓还有很大的空间。

电池仓是从底部推进去的,有四五个卡子,想取出来,要用垫片把每个卡子都垫好,再往外推。我主要是为了检查一下充电头没有虚焊,确认没有问题,就把问题定位到充电线上去了,换一个头略微大一些(micro头上有弹性结构)的充电线就好了。

如果以后想换更大的电池,可以考虑把电池仓抠出来,换一个18650进去。

vue 引进quill-image-resize-module 报错TypeError: Cannot read property ‘imports’ of undefined

首先说解决方案,不止一个,这里发我觉得比较好的一种。

在webpack中添加ProvidePlugin,有两种情况。

webpack.base.conf.js

如果是vuecli2,则会有./build/webpack.base.conf.js这样的文件,添加方式:

如果没有引入webpack则需要:

const webpack = require('webpack')

找到config下的plugins,添加如下代码:

plugins: [
   new webpack.ProvidePlugin({
       'window.Quill': 'quill/dist/quill.js',
       'Quill': 'quill/dist/quill.js'
 })
]

vue.config.js

对于vuecli3,则直接在vue.config.js中找到chainWebpack,添加

chainWebpack: config => {
    // quill-image-resize-module插件报错imports
    config.plugin('provide').use(webpack.ProvidePlugin, [{
      'window.Quill': 'quill/dist/quill.js',
      Quill: 'quill/dist/quill.js'
    }])
}

回过来说一下quill的两种引入方式,一种是直接使用quill,一种是使用vue-quill-editor。

quill

<template>
  <div ref="editor"></div>
</template>
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import Quill from 'quill'
import { ImageDrop } from 'quill-image-drop-module'
import ImageResize from 'quill-image-resize-module'
Quill.register('modules/imageDrop', ImageDrop)
Quill.register('modules/imageResize', ImageResize)
    data() {
    return {
      quill: undefined,
      currentValue: '',
      options: {
        theme: 'snow',
        bounds: document.body,
        debug: 'warn',
        modules: {
          toolbar: [
            ['bold', 'italic', 'underline', 'strike'],
            ['blockquote', 'code-block'],
            [{ list: 'ordered' }, { list: 'bullet' }],
            // [{ 'script': 'sub' }, { 'script': 'super' }],
            [{ indent: '-1' }, { indent: '+1' }],
            // [{ 'direction': 'rtl' }],
            // [{ size: ['small', false, 'large', 'huge'] }],
            [{ header: [1, 2, 3, 4, 5, 6, false] }],
            [{ color: [] }, { background: [] }],
            // [{ 'font': [] }],
            [{ align: [] }],
            ['clean'],
            ['link', 'image']
          ],
          imageDrop: true,
          imageResize: {}  //注意这里的首字母小写,组件官方文档是大写开头,会报错quill Cannot import ImageResize. Are you sure it was registered?
        },
        placeholder: '书写你的内容',
        readOnly: false
      }
    }
  },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      const editor = this.$refs.editor
      // 初始化编辑器
      this.quill = new window.Quill(editor, this.options)
      // 默认值
      this.quill.pasteHTML(this.currentValue)
      // 绑定事件
      this.quill.on('text-change', (delta, oldDelta, source) => {
        const html = this.$refs.editor.children[0].innerHTML
        const text = this.quill.getText()
        const quillSelf = this.quill
        // 更新内部的值
        this.currentValue = html
        // 发出事件 v-model
        this.$emit('input', html)
        // 发出事件
        this.$emit('change', { html, text, quillSelf })
      })
      // 将一些 quill 自带的事件传递出去
      this.quill.on('text-change', (delta, oldDelta, source) => {
        this.$emit('text-change', delta, oldDelta, source)
      })
      this.quill.on('selection-change', (range, oldRange, source) => {
        this.$emit('selection-change', range, oldRange, source)
      })
      this.quill.on('editor-change', (eventName, ...args) => {
        this.$emit('editor-change', eventName, ...args)
      })
    }
  }

vue-quill-editor

<template>
  <div class="hello">
     <quill-editor v-model="content"
                      :options="editorOption"
                      @blur="onEditorBlur($event)"
                      @focus="onEditorFocus($event)"
                      @ready="onEditorReady($event)">
        </quill-editor>
    </div>
</template>

<script>
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import Quill from 'quill'
import { quillEditor } from 'vue-quill-editor'
import { ImageDrop } from 'quill-image-drop-module'
import ImageResize from 'quill-image-resize-module'
Quill.register('modules/imageDrop', ImageDrop)
Quill.register('modules/imageResize', ImageResize)

//自定义字体类型
var fonts = [
  "SimSun",
  "SimHei",
  "Microsoft-YaHei",
  "KaiTi",
  "FangSong",
  "Arial",
  "Times-New-Roman",
  "sans-serif"
];
var Font = Quill.import("formats/font");
Font.whitelist = fonts; //将字体加入到白名单
Quill.register(Font, true);

export default {
  name: 'HelloWorld',
  components: {
    quillEditor
  },
  data () {
    return {
      contentCode:'',
      content: `<p><img src="http://t8.baidu.com/it/u=1484500186,1503043093&fm=79&app=86&size=h300&n=0&g=4n&f=jpeg?sec=1581398243&t=ccf50d7b4dd50dac437d46e368b66b20" width="500"></p>
         `,
     editorOption: {
        modules: {
          toolbar: [
            ['bold', 'italic', 'underline', 'strike', 'image'],
            ['formula', 'clean'],
            ['blockquote', 'code-block'],
            [{'list': 'ordered'}, {'list': 'bullet'}],
            [{'script': 'sub'}, {'script': 'super'}],
            [{'size': ['small', false, 'large', 'huge']}],
            [{ 'font': fonts }],
            [{'header': [1, 2, 3, 4, 5, 6, false]}],
            [{ 'color': [] }, { 'background': [] }],
            [{ 'align': [] }],
            [{'direction': 'rtl'}]
          ],
          history: {
              delay: 1000,
              maxStack: 50,
              userOnly: false
            },
            imageDrop: true,
            imageResize: {
              displayStyles: {
                backgroundColor: 'black',
                border: 'none',
                color: 'white'
              },
              modules: [ 'Resize', 'DisplaySize', 'Toolbar' ]
            }
        },
        placeholder: '输入内容........'
      }
    }
  },
  methods: {
    //vue-quill-editor
    onEditorBlur(quill) {
      // console.log("editor blur!", quill, this.content);
      //this.$emit("editorBlur", this.content);
      this.contentCode=this.content
    },
    onEditorFocus(quill) {
      this.contentCode=this.content
    },
    onEditorReady(quill) {
      // console.log("editor ready!", quill);
    },
    onEditorChange({ quill, html, text }) {
      // console.log("editor change!", quill, html, text);
      this.content = html;
    },
    onEditorChange(quill) {
      // console.log("编辑内容改变!", quill, this.content);
      //this.$emit("editorBlur", this.content);
    },
  },
  mounted() {
    //  console.log("this is current quill instance object", this.editor);
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang='scss'>
</style>