• <legend id='TKVf6'><style id='TKVf6'><dir id='TKVf6'><q id='TKVf6'></q></dir></style></legend>
      <bdo id='TKVf6'></bdo><ul id='TKVf6'></ul>
    <i id='TKVf6'><tr id='TKVf6'><dt id='TKVf6'><q id='TKVf6'><span id='TKVf6'><b id='TKVf6'><form id='TKVf6'><ins id='TKVf6'></ins><ul id='TKVf6'></ul><sub id='TKVf6'></sub></form><legend id='TKVf6'></legend><bdo id='TKVf6'><pre id='TKVf6'><center id='TKVf6'></center></pre></bdo></b><th id='TKVf6'></th></span></q></dt></tr></i><div id='TKVf6'><tfoot id='TKVf6'></tfoot><dl id='TKVf6'><fieldset id='TKVf6'></fieldset></dl></div>
    <tfoot id='TKVf6'></tfoot>

    <small id='TKVf6'></small><noframes id='TKVf6'>

      1. 如何在函数之间传递编辑的wav而不在两者之间保存wav?

        how to pass edited wav between functions without saving wav in between?(如何在函数之间传递编辑的wav而不在两者之间保存wav?)
        <i id='uKzU0'><tr id='uKzU0'><dt id='uKzU0'><q id='uKzU0'><span id='uKzU0'><b id='uKzU0'><form id='uKzU0'><ins id='uKzU0'></ins><ul id='uKzU0'></ul><sub id='uKzU0'></sub></form><legend id='uKzU0'></legend><bdo id='uKzU0'><pre id='uKzU0'><center id='uKzU0'></center></pre></bdo></b><th id='uKzU0'></th></span></q></dt></tr></i><div id='uKzU0'><tfoot id='uKzU0'></tfoot><dl id='uKzU0'><fieldset id='uKzU0'></fieldset></dl></div>
        <legend id='uKzU0'><style id='uKzU0'><dir id='uKzU0'><q id='uKzU0'></q></dir></style></legend>
        • <bdo id='uKzU0'></bdo><ul id='uKzU0'></ul>

                • <tfoot id='uKzU0'></tfoot>

                    <tbody id='uKzU0'></tbody>

                  <small id='uKzU0'></small><noframes id='uKzU0'>

                  本文介绍了如何在函数之间传递编辑的wav而不在两者之间保存wav?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有 2 个人的 wav 对话(客户和技术支持)我有 3 个独立的函数,可以提取 1 个语音,剪切 10 秒并将其转换为嵌入.

                  I have a wav conversation of 2 people(customer and tech support) I have 3 separate functions that extract 1 voice, cut 10 seconds and transform it to embedding.

                  def get_customer_voice(file):
                  
                      print('getting customer voice only')
                      wav = wf.read(file)
                      ch = wav[1].shape[1]#customer voice always in 1st track
                      sr = wav[0]
                      c1 = wav[1][:,1]
                      #print('c0 %i'%c0.size)
                  
                      if ch==1:
                          exit()
                      vad = VoiceActivityDetection()
                      vad.process(c1)
                      voice_samples = vad.get_voice_samples()
                      #this is trouble - how to pass it without saving anywhere as wav?
                      wf.write('%s_customer.wav'%file,sr,voice_samples)
                  

                  下面的函数从上面的函数中截取 10 秒的 wav 文件.

                  function below cuts 10 seconds of wav file from function above.

                  import sys
                  from pydub import AudioSegment
                  
                  def get_customer_voice_10_seconds(file):
                      voice = AudioSegment.from_wav(file)
                      new_voice = voice[0:10000]
                      file = str(file) + '_10seconds.wav'
                      new_voice.export(file, format='wav')
                  
                  
                  if __name__ == '__main__':
                      if len(sys.argv) < 2:
                          print('give wav file to process!')
                      else:
                          print(sys.argv)
                          get_customer_voice_10_seconds(sys.argv[1])
                  

                  如何将它作为 wav 或其他格式传递而不将其保存到某个目录?它是在rest api中使用的,我不知道它会在哪里保存那个wav,所以最好应该以某种方式传递.

                  how to pass it as wav or other format without saving it to some directory? It's to be used in rest api, i don't know where it will save that wav, so preferably it should be passed somehow.

                  推荐答案

                  我想通了——下面的函数不需要保存、缓冲等就可以工作.它接收一个 wav 文件并对其进行编辑,然后直接发送到 get math 嵌入函数:

                  I figured it out - the function below just works without saving, buffer etc. It receives a wav file and edits it and just sends straight to the get math embedding function:

                  def get_customer_voice_and_cutting_10_seconds_embedding(file):
                  
                      print('getting customer voice only')
                      wav = read(file)
                      ch = wav[1].shape[1]
                      sr = wav[0]
                  
                      c1 = wav[1][:,1]
                  
                      vad = VoiceActivityDetection()
                      vad.process(c1)
                      voice_samples = vad.get_voice_samples()
                      audio_segment = AudioSegment(voice_samples.tobytes(), frame_rate=sr,sample_width=voice_samples.dtype.itemsize, channels=1)
                      audio_segment = audio_segment[0:10000]
                      file = str(file) + '_10seconds.wav'
                  
                      return get_embedding(file)
                  

                  关键是音频段中的tobytes(),它只是将它们再次组合到一个轨道中

                  the key is tobytes() in Audio segment, it just assembles all them together in 1 track again

                  这篇关于如何在函数之间传递编辑的wav而不在两者之间保存wav?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                      <small id='FngQO'></small><noframes id='FngQO'>

                    1. <i id='FngQO'><tr id='FngQO'><dt id='FngQO'><q id='FngQO'><span id='FngQO'><b id='FngQO'><form id='FngQO'><ins id='FngQO'></ins><ul id='FngQO'></ul><sub id='FngQO'></sub></form><legend id='FngQO'></legend><bdo id='FngQO'><pre id='FngQO'><center id='FngQO'></center></pre></bdo></b><th id='FngQO'></th></span></q></dt></tr></i><div id='FngQO'><tfoot id='FngQO'></tfoot><dl id='FngQO'><fieldset id='FngQO'></fieldset></dl></div>
                        <bdo id='FngQO'></bdo><ul id='FngQO'></ul>

                        <legend id='FngQO'><style id='FngQO'><dir id='FngQO'><q id='FngQO'></q></dir></style></legend>
                          <tbody id='FngQO'></tbody>
                          • <tfoot id='FngQO'></tfoot>