title: Convert an audio file from mp3 to flac by Flask, and save at Google Cloud Storage
body: <p>I'm trying to create a Flask app that transcribes mp3 files using GCP's speech-to-text and saves the results to Cloud Storage (GCS). (Upload the mp3 file from Vue.js to Flask)
  In the process, I want to convert the mp3 file selected by the user to a flac file, but I do not want to save it locally and throw it to speech-to-text or save it to GCS.</p>
  
  <p>Any module can be used, but I want to save the audio file converted to GCS without going through the local.</p>
  
  <p>I tried to use pydub, which is often used to convert audio files, but the relative path was the only argument that could be taken when selecting the pre-conversion file and where to save the post-conversion file. I cannot convert mp3 files received by Flask to flac files and save them to GCS.</p>
  
  <p>Even if you can't save to GCS, you can save the converted file to variables. I couldn't do that either.</p>
  
  <pre><code>from pydub import AudioSegment
  # (1)I can convert an audio file at the local.
  sound = AudioSegment.from_mp3("example.mp3")
  sound.export("example.flac", format="flac")
  
  # (2)I CANNOT pass GCS URL as an argument
  sound = AudioSegment.from_mp3("https://storage.googleapis.com/&lt;bucket-name&gt;/example.mp3")
  sound.export("https://storage.googleapis.com/&lt;bucket-name&gt;/example.flac", format="flac")
  
  # (3)I CANNOT written to a variable
  sound = sound.export(format="flac")
  sound.export("example.flac")
  </code></pre>
  
  <p>Of the above source code</p>
  
  <p>(1) Shows the expected behavior, and the converted example.flac is saved in the current directory</p>
  
  <p>(2) FileNotFoundError: [Errno 2] No such file or directory: '<a href="https://storage.googleapis.com/" rel="nofollow noreferrer">https://storage.googleapis.com/</a>/npl_speech_2.mp3'</p>
  
  <p>(3) AttributeError: '_io.BufferedRandom' object has no attribute 'export'</p>
  
  <p>In the end, I want to use AWS Lambda, so I want to convert files without going through local.</p>