- 
                Notifications
    You must be signed in to change notification settings 
- Fork 735
Example code for Spectrogram in documentation #1566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
         harishsdev
  
      
      
      commented
      
            harishsdev
  
      
      
      commented
        Jun 10, 2021 
      
    
  
| PR for : #1564 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the con tribulation but your base branch is old more than one month. Please rebase it on master.
        
          
                torchaudio/transforms.py
              
                Outdated
          
        
      | When ``power`` is provided, the value must be False, as the resulting | ||
| Tensor represents real-valued power. | ||
| Example:- | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Indentation is off.
- hyphenand- colonare unnecessary.
Please follow an existing example;
audio/torchaudio/functional/functional.py
Lines 821 to 824 in aec0e8c
| Example | |
| >>> specgram = torch.randn(1, 40, 1000) | |
| >>> delta = compute_deltas(specgram) | |
| >>> delta2 = compute_deltas(delta) | 
        
          
                torchaudio/transforms.py
              
                Outdated
          
        
      | Sample rate of waveform: 8000 | ||
| >>> specgram = torchaudio.transforms.Spectrogram()(waveform) | ||
| >>> print("Shape of spectrogram: {}".format(specgram.size())) | ||
| Shape of spectrogram: torch.Size([2, 201, 1342]) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example spends 6 lines for loading audio tensor and 3 lines for the Transform. Instead please make an example around the transform.
Make the resulting transform instance an intermediate named variable.
Also please use some constructor arguments for showcasing it.
| @mthrok Thanks for inputs I have forked the repository and created Spectrogram branch with following commands rebased,please give me some inputs if i am wrong git remote add upstream https://github.com/pytorch/audio.git git checkout master git rebase upstream/master git push -f origin master | 
| How to run flake in torchaudio for checking pep8 style coding, please suggest | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @harishsdev
You can simple do flake8 torchaudio for flake8.
        
          
                torchaudio/transforms.py
              
                Outdated
          
        
      | >>> specgram = torch.randn(1, 40, 1000) | ||
| >>> specgram = torchaudio.transforms.Spectrogram()(specgram) | ||
| >>> specgram.shape | ||
| torch.Size([1, 40, 201, 6]) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This indentation is too much, there should be only 4 spaces instead of 8.
- Please assign the transform into intermediate variable.
- Please provide some arguments to Spectrogramconstructor.
- The input to Spectrogramshould be calledwaveform.
| Please build the doc by yourself or check the artifact of  https://239906-90321822-gh.circle-artifacts.com/0/docs/transforms.html#spectrogram Also please, do assign the transform object to an intermediate variable to showcase the instantiation of Transform and application of the transform separately. Please do not write them in one line. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please fix the indentation. Build the doc and see that the rendering is correct.
- Please assign the transform into intermediate variable.
        
          
                torchaudio/transforms.py
              
                Outdated
          
        
      | Example | ||
| >>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True) | ||
| >>> transformed_spectrogram = torchaudio.transforms.Spectrogram(n_fft = 800)(waveform) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @harishsdev. Could you assign the transform parameter and move the forward method to a separate line? You can see #1644 as an example.
transform = torchaudio.transforms.Spectrogram(n_fft = 512)
spectrogram = transform(waveform)
| Sure I will update it… On Tue, Aug 3, 2021, 21:25 nateanl ***@***.***> wrote:
 ***@***.**** requested changes on this pull request.
 ------------------------------
 In torchaudio/transforms.py
 <#1566 (comment)>:
 > @@ -67,6 +67,12 @@ class Spectrogram(torch.nn.Module):
              This argument is only effective when ``power=None``. It is ignored for
              cases where ``power`` is a number as in those cases, the returned tensor is
              power spectrogram, which is a real-valued tensor.
 +
 +    Example
 +
 +        >>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True)
 +        >>> transformed_spectrogram = torchaudio.transforms.Spectrogram(n_fft = 800)(waveform)
 Hi @harishsdev <https://github.com/harishsdev>. Could you assign the
 transform parameter and move the forward method to a separate line? You can
 see #1644 <#1644> as an example.
 transform = torchaudio.transforms.Spectrogram(n_fft = 512)
 spectrogram = transform(waveform)
 —
 You are receiving this because you were mentioned.
 Reply to this email directly, view it on GitHub
 <#1566 (review)>,
 or unsubscribe
 <https://github.com/notifications/unsubscribe-auth/ALCDHPVBCAT63CGEZ3DK6QTT3AGOHANCNFSM46O6HLLQ>
 .
 Triage notifications on the go with GitHub Mobile for iOS
 <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
 or Android
 <https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
 .
 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as #1586. We can merge it after addressing the nits.
        
          
                torchaudio/transforms.py
              
                Outdated
          
        
      | Example | ||
| >>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| >>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True) | |
| >>> waveform, sample_rate = torchaudio.load('test.wav', normalize=True) | 
        
          
                torchaudio/transforms.py
              
                Outdated
          
        
      | Example | ||
| >>> waveform, sample_rate = torchaudio.load('test.wav', normalization=True) | ||
| >>> transform = torchaudio.transforms.Spectrogram(n_fft = 800) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| >>> transform = torchaudio.transforms.Spectrogram(n_fft = 800) | |
| >>> transform = torchaudio.transforms.Spectrogram(n_fft=800) | 
        
          
                torchaudio/transforms.py
              
                Outdated
          
        
      | power spectrogram, which is a real-valued tensor. | ||
| Example | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this one. Let's delete the line break.
* Update build.sh Picks up 1.9 build from test. * Update build.sh * Update lite interpreter tutorial to beta (pytorch#1549) * Update lite interpreter tutorial to beta * Update lite interpreter to beta * update model export script * address comment and update documentation * add custome build in first paragraph * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * Update prototype_source/lite_interpreter.rst Co-authored-by: Raziel <[email protected]> * replace file name * update ios part Co-authored-by: Raziel <[email protected]> * Revert "Update lite interpreter tutorial to beta (pytorch#1549)" (pytorch#1569) This reverts commit a702ca0fafe9d4a1ee0c1e4331de66245ceb3103. * Update build.sh * Update build.sh * updated pipeline tutorial (pytorch#1562) * reduce (pytorch#1546) * Update seq2seq_translation_tutorial.py (pytorch#1532) Co-authored-by: Holly Sweeney <[email protected]> * added CPU optimization guide part into tuning_guide (pytorch#1512) * added CPU optimization guide part into tuning_guide * changed non-python command to python comments in CPU specific optimization section * Update tuning_guide.py Changed comment of bash commands to double quote. * Update tuning_guide.py Co-authored-by: Brian Johnson <[email protected]> * Typo fix (pytorch#1538) Co-authored-by: Holly Sweeney <[email protected]> * Typo fix in text sentiment tutorial (pytorch#1543) Trivial typo fix in docs * Update dcgan_faces_tutorial.py (pytorch#1550) Co-authored-by: Holly Sweeney <[email protected]> * updated pipeline tutorial Co-authored-by: define_liuyi <[email protected]> Co-authored-by: dhayeah <[email protected]> Co-authored-by: Holly Sweeney <[email protected]> Co-authored-by: Jing Xu <[email protected]> Co-authored-by: Brian Johnson <[email protected]> Co-authored-by: Andrew C. Freeman <[email protected]> Co-authored-by: Davide Fiocco <[email protected]> Co-authored-by: universuen <[email protected]> * Update audio manipulation tutorial (pytorch#1566) * add resampling tutorial * update benchmarking and sectioning * remove np import * Update torchaudio tutorial * update resample dtype initialization Co-authored-by: moto <[email protected]> * updated text sentiment tutorial (pytorch#1563) * updated transformer tutorial (pytorch#1565) * Update numeric_suite_tutorial.py s/Logger=/logger_cls=/ * Update profiler recipe doc (1.9) (pytorch#1528) Summary: Update the profiler recipe to use the new API and features Test Plan: make html-noplot Co-authored-by: Brian Johnson <[email protected]> * Update build.sh Co-authored-by: cccclai <[email protected]> Co-authored-by: Raziel <[email protected]> Co-authored-by: parmeet <[email protected]> Co-authored-by: define_liuyi <[email protected]> Co-authored-by: dhayeah <[email protected]> Co-authored-by: Holly Sweeney <[email protected]> Co-authored-by: Jing Xu <[email protected]> Co-authored-by: Andrew C. Freeman <[email protected]> Co-authored-by: Davide Fiocco <[email protected]> Co-authored-by: universuen <[email protected]> Co-authored-by: Caroline Chen <[email protected]> Co-authored-by: moto <[email protected]> Co-authored-by: Nikita Shulga <[email protected]> Co-authored-by: ilia-cher <[email protected]>
