
python
谢娘蓝桥
绿水青山境长静,花落虽频意自闲。
展开
-
python 生成tts语音
之前一直使用微软、或者国内大厂的接口,网页操作比较麻烦,最近发现一个python库可以完美解决,在这里分享给大家。生成玩后,调用soundfile 进行播放,有时间做一个上位机界面出来,还是比较实用的。他支持两种形式,一种命令行形式,目前测试下来,有时候不太稳定,不推荐,但是功能相对全些。个人喜欢云溪,就是大家在抖音 b站经常听到的声音 ---哈哈,生产利器呀。另一种是运行python 脚本形式,目前测试下来比较稳定,分享给大家。这里是列举了目前支持的声音版本。原创 2024-11-30 23:06:41 · 490 阅读 · 0 评论 -
声音响度、声压级计权(A B C)实现
A、B、C三种计权网络特性,分别对应于倒置的40、70、100Phon等响曲线(1000Hz归一化到0dB),其作用是分别反应人耳对低、中、高声压级的响度感觉。的余压,它相当于在大气压强上的叠加一个声波扰动引起的压强变化。由于声压的测量比较容易实现,通过声压的测量也可以间接求得质点速度等其它。如下实现 A B C 计权的实现,计权的实现参考标准,用于逼近实际的等响度曲线。70Phon等响曲线的翻转,模拟55~85dB中等强度噪声特性。40Phon等响曲线的翻转,模拟55dB以下低强度噪声特性。原创 2023-11-26 21:19:28 · 2358 阅读 · 0 评论 -
python 使用gcc 生成 exe
3.生成.c 文件注释掉原来定义,使用下面方法。4.输入下面命令生成exe 文件。2.编写脚本输出 .c 文件。1. 编写原始t.py文件。原创 2022-11-11 14:11:06 · 537 阅读 · 0 评论 -
python 画图
【代码】python 画图。原创 2022-10-20 00:48:54 · 430 阅读 · 0 评论 -
python 数的计算
让第二个数比第一个小 递归实现。原创 2022-08-04 15:45:41 · 381 阅读 · 0 评论 -
mpy button 按键消抖
import timefrom machine import Pinclass button: def __init__(self, pin, callback=None, trigger=Pin.IRQ_RISING, min_ago=200): #print("button init") self.callback = callback self.min_ago = min_ago self._ne.原创 2022-02-24 15:20:23 · 523 阅读 · 0 评论 -
mpy lcd 绘制圆
1.实心def drawCirc_fill(tft,x,y,r,pen): ox =r oy =0 err = -r while ox>=oy: last_oy = oy err +=oy oy+=1 err+=oy tft.hline(x-ox,y+last_oy,ox*2+1,pen) ##3 if last_oy != 0: tft.hli原创 2022-02-24 13:28:04 · 2101 阅读 · 0 评论 -
pico micro python ssd1306中文显示
默认只能用text 进行字符显示,使用framebuff 进行图像显示后来整理下用字库生成16*16 8*16汉字和英文字模型混输入。原创 2021-12-12 14:37:17 · 2522 阅读 · 0 评论 -
python wav 录音
import pyaudioimport wavefrom tqdm import tqdm def record_audio(wave_out_path,record_second): CHUNK = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 2 RATE = 44100 p = pyaudio.PyAudio() stream = p.open(format=FORMAT, .原创 2021-12-09 14:04:11 · 2699 阅读 · 0 评论 -
Pyqt qtimer使用
from PyQt5.QtWidgets import QApplicationfrom PyQt5.QtCore import QTimerimport systimer = QTimer()count =0def outfunc(): global timer global count count +=1 print(count) if(count==20): timer.stop()if __name__ == "__main__".原创 2021-09-16 08:50:13 · 212 阅读 · 0 评论 -
python pdf转docx
主要使用了pdf2docx 及 pyqt。qt ui 界面# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'conv.ui'## Created by: PyQt5 UI code generator 5.15.4## WARNING: Any manual changes made to this file will be lost when pyuic5 is# ru...原创 2021-08-16 16:52:00 · 345 阅读 · 0 评论 -
正弦波低mips低存储产生的方法
import numpy as npimport matplotlib.pyplot as pltimport pandas as pd%matplotlib inlineplt.rcParams['font.sans-serif']= ['SimHei']plt.rcParams['axes.unicode_minus'] = Falsedef xSin(x): #x is scaled 0<=x<4096 A=-0.40319426317E-08 B=.原创 2021-07-06 19:40:16 · 101 阅读 · 0 评论 -
jupyter使用技巧
1.模块重载有时候我们需要重新import之前已经导入的模块,代码已经跑了一半了?重启?那是不可能的。在启动jupyter第一个cell运行下面代码,就可以在notebook外改模块代码啦,notebook会自动重载的。%load_ext autoreload %autoreload 22.cell 合并!pip install nbmerge !nbmerge file_1.ipynb file_2.ipynb file_3.ipynb > merged.ipynb3.原创 2021-07-06 17:00:42 · 822 阅读 · 0 评论 -
python wav转 bin wav 重采样 wav格式转换wavplay实现
# -*- coding = utf-8 -*-import wave as weimport osimport audioopfrom ctypes import *import structimport binascii#################### define params ##############################inputfile= "\\Chime" ## wav file dir 原始wav文件地址,文件排序是文件名前两位,请注意,否.原创 2021-06-15 20:31:44 · 884 阅读 · 2 评论 -
python wav 转c 数组 、bin功能实现
import waveimport argparseimport os.pathimport struct#prepare an argument parserparser = argparse.ArgumentParser(description='Convert .wav to .bin or C-style Array.')parser.add_argument('input')parser.add_argument('-o',metavar = '<output>').原创 2021-06-15 20:29:59 · 1140 阅读 · 2 评论 -
PCM转wav或者 txt 一维数组转wav文件
1.PCM文件转wav#!/usr/bin/env python# coding: utf-8#coding=utf-8import osimport waveall_file_list =[]## 获取路径下的pcm文件def get_all_filepath(dir): parents = os.listdir(dir) for parent in parents: child = os.path.join(dir,parent)原创 2021-01-28 18:46:44 · 924 阅读 · 2 评论 -
python 数据精度比对
import os,mathimport numpy as npimport matplotlib.pyplot as plt#约定俗成的写法pltplt.rcParams['font.sans-serif']=['SimHei']plt.rcParams['axes.unicode_minus'] = False#matplotlib画图中中文显示会有问题,需要这两行设置默认字体def readtxt(file): try: f = open(file) e.原创 2021-01-11 09:47:50 · 546 阅读 · 2 评论 -
半带宽滤波器实现
# The following is a Python/scipy snippet to generate the # coefficients for a halfband filter. A halfband filter# is a filter where the cutoff frequency is Fs/4 and every# other coeffecient is zero except the cetner tap.# Note: every other (even exc.原创 2021-01-06 18:14:15 · 599 阅读 · 1 评论 -
python handcalcs使用
项目开源地址 github.com/connorferster/handcalcsfrom math import sqrtimport handcalcs.render数据显示%%render#Parametersa =2b =-5c =3a=2b=−5c=3\begin{aligned}a &= 2 &b &= -5 &c &= 3\\\end{aligned}a=2b=−5c=3 %%render# Symbolic原创 2020-08-20 10:21:57 · 2078 阅读 · 4 评论 -
python获取目录下指定后缀名的文件
import osall_file_list =[]## 获取路径下的png文件def get_all_filepath(dir): parents = os.listdir(dir) for parent in parents: child = os.path.join(dir,parent) if os.path.isdir(child): get_all_filepath(child) else: .原创 2020-06-29 10:56:04 · 1301 阅读 · 0 评论 -
Urllib 常用操作
urlliburllib.request.urlopen(url, data=None, [timeout, ]*, cafile=None, capath=None, cadefault=False, context=None)In[3]:import urllib.requestrespose = urllib.request.urlopen('http://www.baid...原创 2020-02-08 13:59:24 · 8809 阅读 · 0 评论 -
Jupyter notebook 教程
jupyter notebook 教程快捷键非编辑状态下 A B 添加 cell M 转换为markdown Y转换为code 两次D 会 删除当前cell Z 撤销删除 按住shift+ 上下键选择多个cell //也可以 按住shift+ctrl +鼠标左键选取In [1]:##加载库 等待三秒import timetime.sleep(3)In [2]:...原创 2019-01-18 19:47:46 · 304 阅读 · 0 评论 -
Jupyter notebook 使用技巧
1.安装使用通过安装anaconda 在自带的Navigator 图形界面打开Notebook ,或者直接命令行输入jupyter notebook会自动打开。2.界面在View -》Toggle Line Numbers 来显示行号3.快捷键1.当前单元用shift+Enter 运行当前单元。2.编辑模式 选中单元按Enter键进入编辑模式。 命令模式 通过Es...原创 2019-01-03 10:46:54 · 307 阅读 · 0 评论 -
anaconda keras 安装
安装顺序1.安装mingw libpythonconda install mingw libpython2.安装theanoconda install theano3.安装kerasconda install keras出现错误>>> import kerasUsing TensorFlow backend.解决方法 在命令行输入:pi...原创 2019-01-02 11:10:05 · 1187 阅读 · 0 评论 -
用python进行天气查询
#-*-coding:utf-8 -*-import requestsimport jsonimport os,redef get(): print("天气查询小工具") str = input("请输入查询的城市:(汉字吆)") url ='http://wthrcdn.etouch.cn/weather_mini?city='+str respon...原创 2019-01-11 10:41:06 · 2559 阅读 · 0 评论 -
python 计算圆周率
from datetime import datetimedef pi(places=10): extra = 8; one = 10**(places+extra) t, c, n, na, d, da = 3*one, 3*one, 1, 0, 0, 24 while t > 1: n, na, d, da = n+na, na+...原创 2018-12-07 10:09:29 · 1819 阅读 · 0 评论 -
jupyter notebook解决输出pdf问题
详细可参考https://stackoverflow.com/questions/29156653/ipython-jupyter-problems-saving-notebook-as-pdf/52913424#52913424 大致过程是 :1.首先必须安装着两个nbconvert pandocpip install nbconvert pandoc# OR...原创 2019-01-18 20:46:57 · 4977 阅读 · 0 评论 -
图像数据增强的方法
图像数据增强的方法(不能改变图像的原有标签)平移:一定尺度内平移 旋转:一定角度内旋转 翻转:水平或者上下翻转 裁剪:在原有图像上裁剪一部分 颜色变化:rgb颜色空间进行一些变换(亮度对比度等) 噪声扰动:给图像加入一些人工生产的噪声作用:提高模型的性能,提高模型的泛化能力,能够预防过拟合...原创 2019-01-24 14:41:40 · 4418 阅读 · 0 评论 -
python 获取天气实现 续
#-*-coding:utf-8 -*-import requestsimport jsonimport os,redef get(): str = input("请输入查询的城市:(汉字吆)") url ='http://wthrcdn.etouch.cn/weather_mini?city='+str response= requests.get(url)...原创 2019-01-14 18:18:24 · 879 阅读 · 0 评论 -
termux 安装matplot numpy 等工具包
1.先安装工具pkg install wget nmap hydra python python-dev python2 python2-dev curl tsu vim wget git unzip unrar sl clang nodejs php cmatrix tree toilet figlet cowsay w3m htop screenfetch aria2 tmux pro...原创 2019-05-01 21:52:10 · 4088 阅读 · 0 评论 -
microPython 交互式解释器模式(又称REPL)
1.自动缩进 以冒号结尾的python语句(如if for while)自动缩进2.自动完成 REPL中键入命令时,如果到目前为止键入的行对应于某个名称的开头,则按TAB将显示可输入的内容。例如,首先通过输入并按RETURN导入机器模块。然后键入并按TAB键,它应扩展为。输入一个点并再次按TAB键。你应该看到类似的东西:importmachinemmachine.help...原创 2019-05-12 14:11:55 · 2580 阅读 · 2 评论 -
python 字符串固定长度截取
参考了https://blog.youkuaiyun.com/C42427106/article/details/79819193但长度正好为lenth的整数倍时,会多一个' '的单元,所以做了一下整理## 固定长度拆分字符串def cut_text(text,lenth): textArr = re.findall(r'.{'+str(lenth)+'}', text) text...原创 2019-06-21 17:34:45 · 5584 阅读 · 0 评论 -
python C语言加速
查看了公众号的文章https://mp.weixin.qq.com/s/CCokmNsTjspCUjgVbXU2Xg首先要安装cython (pip install Cython)首先使用python运行下面程序调用cython可以看到时间大大减少了...原创 2019-08-06 10:25:11 · 784 阅读 · 0 评论 -
mac 下安装 labelImg
https://github.com/tzutalin/labelImg 参考GitHub教程安装没有成功。自己摸索了一个方法 如下:1.先要安装pyqt5 及 libxml2pip install qtpip install libxml22. 直接pip install labelImg(注意I大写)3.有时会报错缺少model 直接用pip install 进行安装 ...原创 2018-09-30 00:55:41 · 2288 阅读 · 1 评论