#测试程序
import os
from pydub import AudioSegment #已经确定, # enPath = "%s%s/%s"%(enDir,file,enfile) #英文文件的路径 # cnPath = "%s%s/%s"%(cnDir,file,enfile.replace("en_w","cn_w"))#中文文件的路径 path1 = "C:\\Users\\Administrator\\Desktop\\233春晓.mp3"
p1,f1=os.path.split(path1)
# sound1 = AudioSegment.from_file(path1, format=os.path.splitext(f1)[1][-3:]) sound1 = AudioSegment.from_mp3(path1) print(len(sound1))
sound_mix = AudioSegment.empty()
print(len(sound_mix))
data_play = ['', ',', '', '.', '', ',', '', '.', '', ',', '', '.']
time_end = int(data_play[0])*100
print(time_end)
# sound_mix = sound_mix + sound1[1,time_end]
sound_mix = sound1[0,3300]
print(len(sound_mix)) # song1 = AudioSegment.from_mp3(enPath) # song2 = AudioSegment.from_mp3(cnPath)

问题显示:

22544
0
3300
Traceback (most recent call last):
File "C:\Users\Administrator\OneDrive\Mufasa Code\audio lay\test_数据读取的音频合成.pyw", line 26, in <module>
sound_mix = sound1[0,3300]
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-packages\pydub\audio_segment.py", line 247, in __getitem__
end = millisecond + 1
TypeError: can only concatenate tuple (not "int") to tuple
请按任意键继续. . .

原因:

sound_mix = sound1[0,3300]
应该为数组类型
sound1[0:3300]
:::

can only concatenate tuple (not "int") to tuple问题原因的更多相关文章

  1. Python之创建tuple和“可变”的tuple

    Python之创建tuple tuple是另一种有序的列表,中文翻译为" 元组 ".tuple 和 list 非常类似,但是,tuple一旦创建完毕,就不能修改了. 同样是表示班里 ...

  2. python产生错误:can only concatenate str (not "int") to str

    代码为: #!/usr/bin/python # _*_ coding:utf-8_*_ # print("hello world!") name = input("na ...

  3. str int list tuple dict 一些实操

    #字符串的 一些实操 a='what' b=' are ' c=' you ' print(a+b+c) #字符串拼接 m =a.split('+') #以什么分割 (代码a='w+ha+t' 输出[ ...

  4. Python中的数据结构 --- 元组(tuple)、字典(tuple)

       元组(tuple)本身是不可变数据类型,没有增删改查:元组内可以存储任意数据类型一.元组的创建 例:t = (1,2.3,'star',[1,2,3])      ## 元组里面包含可变类型,故 ...

  5. 【问题记录】Python运行报错:can only concatenate str (not "int") to str

    自己总是写程序时候用 + 拼接的时候忘记变量类型要一致,如下面 frame_num = "1" for i in range(1, frame_num + 1, 1): self. ...

  6. TypeError: can only concatenate str (not "int") to str解决方式

    使用format函数解决问题 for page in range(1,pagebox+1): url = "https://www.dd373.com/s/rbg22w-x9kjbs-wwf ...

  7. Python元组(tuple)

    元组(tuple)是Python中另一个重要的序列结构,与列表类型,也是由一系列按特定顺序排列的元素组成,但是他是不可变序列.在形式上元组的所有元素都放在"()"中,两个元素使用& ...

  8. C# Tuple<T1,T2....T>元组的使用

    1) 先说组元:一个数据结构,由通过逗号分割的,用于传递给一个程序或者操作系统的一系列值的组合. NET Framework 直接支持一至七元素的元组 Tuple<T1> Tuple< ...

  9. Tuple<T1,T2,.........T> 元组简单使用

    元组:一个数据结构,逗号分隔,用于传递一个程序或者操作系统的一系列值得组合 NET Framework直接支持一至七元素得数组 Tuple<T1> Tuple<T1,T2> T ...

随机推荐

  1. 将python、pip 加入环境变量

    加python: CMD里输:    path=%path%;C:\Python27 其中   C:\Python27  为python的exe所在的文件夹 加pip: CMD里输:    path= ...

  2. CO-产地证--需要的国家以及操作流程。

    需要产地证的国家一般是与中国有合作的亚非拉国家,比如: 巴基斯坦.智利.以色列.韩国.土耳其.越南.澳大利亚. 流程: 1.在海关官网上填报信息. 2.提交,客户在他国家的官网上确认. 3.确认无误后 ...

  3. GCD - Extreme (II) (欧拉函数妙用)

    https://cn.vjudge.net/problem/UVA-11426 题意:求 解题思路:我们可以定义一个变量dis[n],dis[n]意为1~(n-1)与n的gcd(最大公约数)的总和,那 ...

  4. 251. Flatten 2D Vector 平铺二维矩阵

    [抄题]: Implement an iterator to flatten a 2d vector. Example: Input: 2d vector = [ [1,2], [3], [4,5,6 ...

  5. 105. Construct Binary Tree from Preorder and Inorder Traversal根据前中序数组恢复出原来的树

    [抄题]: Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume ...

  6. ES6的let和const的不同点

    详细的异同点请点击:https://blog.csdn.net/zhouziyu2011/article/details/71366078

  7. powerDesigner 正向工程生成sql注释

    找到script-->objects-->column-->add value内容如下: %:COLUMN% %:DATATYPE%[.Z:[%Compressed%? compre ...

  8. 【APP测试(Android)】--性能测试

  9. vector容器用法详解

    vector类称作向量类,它实现了动态数组,用于元素数量变化的对象数组.像数组一样,vector类也用从0开始的下标表示元素的位置:但和数组不同的是,当vector对象创建后,数组的元素个数会随着ve ...

  10. brew安装和换源

    命令行执行ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&q ...